Class: PromisePool::Task
- Inherits:
-
Struct
- Object
- Struct
- PromisePool::Task
- Defined in:
- lib/promise_pool/task.rb
Instance Attribute Summary collapse
-
#cancelled ⇒ Object
Returns the value of attribute cancelled.
-
#job ⇒ Object
Returns the value of attribute job.
-
#mutex ⇒ Object
Returns the value of attribute mutex.
-
#thread ⇒ Object
Returns the value of attribute thread.
Instance Method Summary collapse
-
#call(working_thread) ⇒ Object
this should never fail.
- #cancel ⇒ Object
Instance Attribute Details
#cancelled ⇒ Object
Returns the value of attribute cancelled
3 4 5 |
# File 'lib/promise_pool/task.rb', line 3 def cancelled @cancelled end |
#job ⇒ Object
Returns the value of attribute job
3 4 5 |
# File 'lib/promise_pool/task.rb', line 3 def job @job end |
#mutex ⇒ Object
Returns the value of attribute mutex
3 4 5 |
# File 'lib/promise_pool/task.rb', line 3 def mutex @mutex end |
#thread ⇒ Object
Returns the value of attribute thread
3 4 5 |
# File 'lib/promise_pool/task.rb', line 3 def thread @thread end |
Instance Method Details
#call(working_thread) ⇒ Object
this should never fail
5 6 7 8 9 10 11 12 |
# File 'lib/promise_pool/task.rb', line 5 def call working_thread mutex.synchronize do return if cancelled self.thread = working_thread end job.call true end |
#cancel ⇒ Object
14 15 16 |
# File 'lib/promise_pool/task.rb', line 14 def cancel self.cancelled = true end |