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.
144 145 146 |
# File 'lib/asir/thread_pool.rb', line 144 def block @block end |
#finished ⇒ Object
Returns the value of attribute finished.
145 146 147 |
# File 'lib/asir/thread_pool.rb', line 145 def finished @finished end |
#started ⇒ Object
Returns the value of attribute started.
145 146 147 |
# File 'lib/asir/thread_pool.rb', line 145 def started @started end |
#thread ⇒ Object
Returns the value of attribute thread.
144 145 146 |
# File 'lib/asir/thread_pool.rb', line 144 def thread @thread end |
#work_id ⇒ Object
Returns the value of attribute work_id.
144 145 146 |
# File 'lib/asir/thread_pool.rb', line 144 def work_id @work_id end |
#worker ⇒ Object
Returns the value of attribute worker.
144 145 146 |
# File 'lib/asir/thread_pool.rb', line 144 def worker @worker end |
Instance Method Details
#inspect ⇒ Object
148 |
# File 'lib/asir/thread_pool.rb', line 148 def inspect; to_s; end |
#run! ⇒ Object
150 151 152 153 154 155 156 157 158 159 |
# File 'lib/asir/thread_pool.rb', line 150 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
160 |
# File 'lib/asir/thread_pool.rb', line 160 def thread_pool; @worker.thread_pool; end |
#to_s ⇒ Object
147 |
# File 'lib/asir/thread_pool.rb', line 147 def to_s; super.sub(/>$/, " #{@work_id}>"); end |