Sha256: 33ba5e038dbd5f24b2f82a88e2377f59b1119a7c2a9721f302db5bd5fb65c214

Contents?: true

Size: 434 Bytes

Versions: 6

Compression:

Stored size: 434 Bytes

Contents

require 'fastthread'
class AsyncFu
  def initialize(obj = nil)
    @class = obj || self
    @guard = Mutex.new
    at_exit{
      unless @exit
        until Thread.list.size == 1 do Thread.pass end
      end
    }
  end
  def method_missing(name, *args)
    if @class.respond_to?(name)
      Thread.new{
        @class.send name, *args
      }
    else
      @class.send name, *args
    end
  end
  def exit
    @exit = true
  end
end

Version data entries

6 entries across 5 versions & 1 rubygems

Version Path
amirka-async-fu-1.1.0 lib/async_fu.rb
amirka-async-fu-1.1.1 lib/async_fu.rb
amirka-async-fu-1.1.1 test/lib/async_fu.rb
amirka-async-fu-1.1.2 test/lib/async_fu.rb
amirka-async-fu-1.1.3 test/lib/async_fu.rb
amirka-async-fu-1.1.4 test/lib/async_fu.rb