Class: Elevate::Future
- Inherits:
-
Object
- Object
- Elevate::Future
- Defined in:
- lib/elevate/future.rb
Constant Summary collapse
- OUTSTANDING =
0
- FULFILLED =
1
Instance Method Summary collapse
- #fulfill(value) ⇒ Object
-
#initialize ⇒ Future
constructor
A new instance of Future.
- #value ⇒ Object
Constructor Details
#initialize ⇒ Future
Returns a new instance of Future.
6 7 8 9 |
# File 'lib/elevate/future.rb', line 6 def initialize @lock = NSConditionLock.alloc.initWithCondition(OUTSTANDING) @value = nil end |
Instance Method Details
#fulfill(value) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/elevate/future.rb', line 11 def fulfill(value) if @lock.tryLockWhenCondition(OUTSTANDING) @value = value @lock.unlockWithCondition(FULFILLED) end end |