Class: Dispatch::BackgroundUnit
- Defined in:
- lib/carat-dev/detach/detach.rb
Overview
These are created for each background work unit (method call) that is created. They keep stats and allow for indexing when the value is ready.
Instance Attribute Summary collapse
-
#start ⇒ Object
Returns the value of attribute start.
-
#stop ⇒ Object
Returns the value of attribute stop.
-
#thread ⇒ Object
Returns the value of attribute thread.
-
#unit_id ⇒ Object
Returns the value of attribute unit_id.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#elapse ⇒ Object
Indicates the elapse time spent on the unit.
-
#initialize(id) ⇒ BackgroundUnit
constructor
A new instance of BackgroundUnit.
-
#ready? ⇒ Boolean
Indicates if the unit has finished processing.
Constructor Details
#initialize(id) ⇒ BackgroundUnit
Returns a new instance of BackgroundUnit.
43 44 45 46 47 48 |
# File 'lib/carat-dev/detach/detach.rb', line 43 def initialize(id) @unit_id = id @thread = nil @start = nil @stop = nil end |
Instance Attribute Details
#start ⇒ Object
Returns the value of attribute start.
40 41 42 |
# File 'lib/carat-dev/detach/detach.rb', line 40 def start @start end |
#stop ⇒ Object
Returns the value of attribute stop.
40 41 42 |
# File 'lib/carat-dev/detach/detach.rb', line 40 def stop @stop end |
#thread ⇒ Object
Returns the value of attribute thread.
41 42 43 |
# File 'lib/carat-dev/detach/detach.rb', line 41 def thread @thread end |
#unit_id ⇒ Object
Returns the value of attribute unit_id.
40 41 42 |
# File 'lib/carat-dev/detach/detach.rb', line 40 def unit_id @unit_id end |
#value ⇒ Object
Returns the value of attribute value.
41 42 43 |
# File 'lib/carat-dev/detach/detach.rb', line 41 def value @value end |
Instance Method Details
#elapse ⇒ Object
Indicates the elapse time spent on the unit
63 64 65 |
# File 'lib/carat-dev/detach/detach.rb', line 63 def elapse @stop - @start end |
#ready? ⇒ Boolean
Indicates if the unit has finished processing
68 69 70 |
# File 'lib/carat-dev/detach/detach.rb', line 68 def ready? !@thread.alive? end |