Class: MrDarcy::Promise::Thread
- Defined in:
- lib/mr_darcy/promise/thread.rb
Overview
Implementation of promises using Ruby threads and locks.
See MrDarcy::Promise::Base for method information.
Instance Method Summary collapse
- #final ⇒ Object
-
#initialize(*args) ⇒ Thread
constructor
A new instance of Thread.
- #result ⇒ Object
Methods inherited from Base
#fail, #raise, #reject, #resolve, #then
Constructor Details
#initialize(*args) ⇒ Thread
11 12 13 14 15 |
# File 'lib/mr_darcy/promise/thread.rb', line 11 def initialize *args @semaphore = Mutex.new semaphore.synchronize { @complete = false } super end |
Instance Method Details
#final ⇒ Object
22 23 24 25 |
# File 'lib/mr_darcy/promise/thread.rb', line 22 def final wait_if_unresolved self end |
#result ⇒ Object
17 18 19 20 |
# File 'lib/mr_darcy/promise/thread.rb', line 17 def result wait_if_unresolved value end |