lib/elevate/promise.rb in elevate-0.3.1 vs lib/elevate/promise.rb in elevate-0.3.2
- old
+ new
@@ -6,22 +6,23 @@
def initialize
@lock = NSConditionLock.alloc.initWithCondition(OUTSTANDING)
@result = nil
end
- def get
+ def fulfill(result)
+ if @lock.tryLockWhenCondition(OUTSTANDING)
+ @result = result
+ @lock.unlockWithCondition(FULFILLED)
+ end
+ end
+
+ def value
result = nil
@lock.lockWhenCondition(FULFILLED)
result = @result
@lock.unlockWithCondition(FULFILLED)
result
- end
-
- def set(result)
- @lock.lockWhenCondition(OUTSTANDING)
- @result = result
- @lock.unlockWithCondition(FULFILLED)
end
end
end