Class: ASIR::ThreadPool::Work

Inherits:
Object
  • Object
show all
Includes:
AdditionalData, Initialization
Defined in:
lib/asir/thread_pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Initialization

#initialize

Methods included from AdditionalData

#[], #[]=, #_additional_data, #additional_data, #additional_data!, #additional_data=, included

Instance Attribute Details

#blockObject

Returns the value of attribute block.



143
144
145
# File 'lib/asir/thread_pool.rb', line 143

def block
  @block
end

#finishedObject

Returns the value of attribute finished.



144
145
146
# File 'lib/asir/thread_pool.rb', line 144

def finished
  @finished
end

#startedObject

Returns the value of attribute started.



144
145
146
# File 'lib/asir/thread_pool.rb', line 144

def started
  @started
end

#threadObject

Returns the value of attribute thread.



143
144
145
# File 'lib/asir/thread_pool.rb', line 143

def thread
  @thread
end

#work_idObject

Returns the value of attribute work_id.



143
144
145
# File 'lib/asir/thread_pool.rb', line 143

def work_id
  @work_id
end

#workerObject

Returns the value of attribute worker.



143
144
145
# File 'lib/asir/thread_pool.rb', line 143

def worker
  @worker
end

Instance Method Details

#inspectObject



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_poolObject



159
# File 'lib/asir/thread_pool.rb', line 159

def thread_pool; @worker.thread_pool; end

#to_sObject



146
# File 'lib/asir/thread_pool.rb', line 146

def to_s; super.sub(/>$/, " #{@work_id}>"); end