lib/lightio/core/future.rb in lightio-0.1.1 vs lib/lightio/core/future.rb in lightio-0.2.0
- old
+ new
@@ -20,21 +20,25 @@
# Transfer and set result value
#
# use this method to set back result
def transfer(value=nil)
- raise Error, "state error" if done?
+ raise LightIO::Error, "state error" if done?
@value = value
done!
@light_fiber.transfer if @light_fiber
end
+ def value=(value)
+ transfer(value)
+ end
+
# Get value
#
# this method will block current beam/fiber, until future result is set.
def value
return @value if done?
- raise Error, 'already used' if @light_fiber
+ raise LightIO::Error, 'already used' if @light_fiber
@light_fiber = LightFiber.current
@ioloop.transfer
@value
end
\ No newline at end of file