Class: DatWorkerPool::DefaultQueue
- Inherits:
-
Object
- Object
- DatWorkerPool::DefaultQueue
- Includes:
- Queue
- Defined in:
- lib/dat-worker-pool/default_queue.rb
Instance Attribute Summary collapse
-
#on_pop_callbacks ⇒ Object
readonly
Returns the value of attribute on_pop_callbacks.
-
#on_push_callbacks ⇒ Object
readonly
Returns the value of attribute on_push_callbacks.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize ⇒ DefaultQueue
constructor
A new instance of DefaultQueue.
- #on_pop(&block) ⇒ Object
- #on_push(&block) ⇒ Object
- #work_items ⇒ Object
Methods included from Queue
Constructor Details
#initialize ⇒ DefaultQueue
12 13 14 15 16 17 18 |
# File 'lib/dat-worker-pool/default_queue.rb', line 12 def initialize @work_items = LockedArray.new @cond_var = ConditionVariable.new @on_push_callbacks = [] @on_pop_callbacks = [] end |
Instance Attribute Details
#on_pop_callbacks ⇒ Object (readonly)
Returns the value of attribute on_pop_callbacks.
10 11 12 |
# File 'lib/dat-worker-pool/default_queue.rb', line 10 def on_pop_callbacks @on_pop_callbacks end |
#on_push_callbacks ⇒ Object (readonly)
Returns the value of attribute on_push_callbacks.
10 11 12 |
# File 'lib/dat-worker-pool/default_queue.rb', line 10 def on_push_callbacks @on_push_callbacks end |
Instance Method Details
#empty? ⇒ Boolean
21 |
# File 'lib/dat-worker-pool/default_queue.rb', line 21 def empty?; @work_items.empty?; end |
#on_pop(&block) ⇒ Object
24 |
# File 'lib/dat-worker-pool/default_queue.rb', line 24 def on_pop(&block); @on_pop_callbacks << block; end |
#on_push(&block) ⇒ Object
23 |
# File 'lib/dat-worker-pool/default_queue.rb', line 23 def on_push(&block); @on_push_callbacks << block; end |
#work_items ⇒ Object
20 |
# File 'lib/dat-worker-pool/default_queue.rb', line 20 def work_items; @work_items.values; end |