Sha256: 4ea00bbad851016d9cc74d74059371b236f712ed10c8814c4291f974659b4183
Contents?: true
Size: 615 Bytes
Versions: 1
Compression:
Stored size: 615 Bytes
Contents
# Future, provide another way to operate Beam and Ioloop module LightIO class Future def initialize @value = nil @ioloop = IOloop.current @state = :init end def done? @state == :done end def done! @state = :done end # transfer and set value def transfer(value=nil) raise Error, "state error" if done? @value = value done! @beam.transfer if @beam end # block current beam/fiber and get value def value return @value if done? @beam = Beam.current @ioloop.transfer @value end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lightio-0.1.0.pre | lib/lightio/future.rb |