class APromise
Constants
- NOT_SPECIFIED
- VERSION
Constants ============================================================¶ ↑
Public Class Methods
new(value: NOT_SPECIFIED) { || ... }
click to toggle source
Instance Methods =====================================================¶ ↑
Calls superclass method
# File lib/apromise.rb, line 22 def initialize(value: NOT_SPECIFIED) if (block_given?) begin @value = yield rescue Exception => e @value = e end elsif (value === NOT_SPECIFIED) # Do nothing else @value = value end super() end
Public Instance Methods
resolve(value: nil, task: nil) { || ... }
click to toggle source
# File lib/apromise.rb, line 46 def resolve(value: nil, task: nil) @value = value if (block_given?) begin @value = yield rescue Exception => e @value = e end end reactor = (task ||= Async::Task.current).reactor reactor << Async::Notification::Signal.new(@waiting, @value) reactor.yield @waiting = [ ] nil end
resolved?()
click to toggle source
# File lib/apromise.rb, line 42 def resolved? defined?(@value) end
wait()
click to toggle source
Calls superclass method
# File lib/apromise.rb, line 67 def wait if (defined?(@value)) case (@value) when Exception raise @value else return @value end end super end
waiting?()
click to toggle source
# File lib/apromise.rb, line 38 def waiting? @waiting.any? end