Class: ASIR::ThreadPool::Work
- Inherits:
-
Object
- Object
- ASIR::ThreadPool::Work
- Includes:
- AdditionalData, Initialization
- Defined in:
- lib/asir/thread_pool.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#finished ⇒ Object
Returns the value of attribute finished.
-
#started ⇒ Object
Returns the value of attribute started.
-
#thread ⇒ Object
Returns the value of attribute thread.
-
#work_id ⇒ Object
Returns the value of attribute work_id.
-
#worker ⇒ Object
Returns the value of attribute worker.
Instance Method Summary collapse
Methods included from Initialization
Methods included from AdditionalData
#[], #[]=, #_additional_data, #additional_data, #additional_data!, #additional_data=, included
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
143 144 145 |
# File 'lib/asir/thread_pool.rb', line 143 def block @block end |
#finished ⇒ Object
Returns the value of attribute finished.
144 145 146 |
# File 'lib/asir/thread_pool.rb', line 144 def finished @finished end |
#started ⇒ Object
Returns the value of attribute started.
144 145 146 |
# File 'lib/asir/thread_pool.rb', line 144 def started @started end |
#thread ⇒ Object
Returns the value of attribute thread.
143 144 145 |
# File 'lib/asir/thread_pool.rb', line 143 def thread @thread end |
#work_id ⇒ Object
Returns the value of attribute work_id.
143 144 145 |
# File 'lib/asir/thread_pool.rb', line 143 def work_id @work_id end |
#worker ⇒ Object
Returns the value of attribute worker.
143 144 145 |
# File 'lib/asir/thread_pool.rb', line 143 def worker @worker end |
Instance Method Details
#inspect ⇒ Object
147 |
# File 'lib/asir/thread_pool.rb', line 147 def inspect; to_s; end |
#run! ⇒ Object
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/asir/thread_pool.rb', line 149 def run! @thread = ::Thread.current thread_pool.work_starting! self @started = true @block.call @finished = true ensure @thread = nil thread_pool.work_stopping! self end |
#thread_pool ⇒ Object
159 |
# File 'lib/asir/thread_pool.rb', line 159 def thread_pool; @worker.thread_pool; end |
#to_s ⇒ Object
146 |
# File 'lib/asir/thread_pool.rb', line 146 def to_s; super.sub(/>$/, " #{@work_id}>"); end |