Class: Wonkavision::LocalJobQueue
- Inherits:
-
Object
- Object
- Wonkavision::LocalJobQueue
- Defined in:
- lib/wonkavision/local_job_queue.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ LocalJobQueue
constructor
A new instance of LocalJobQueue.
- #publish(event_path, event) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ LocalJobQueue
Returns a new instance of LocalJobQueue.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/wonkavision/local_job_queue.rb', line 6 def initialize(={}) worker_count = [:workers] || 2 @queue = Queue.new @workers = [] worker_count.times do Thread.new do while true if msg = @queue.pop Wonkavision.event_coordinator.receive_event(msg[0],msg[1]) else sleep 0.1 end end end end end |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
5 6 7 |
# File 'lib/wonkavision/local_job_queue.rb', line 5 def queue @queue end |
Instance Method Details
#publish(event_path, event) ⇒ Object
23 24 25 |
# File 'lib/wonkavision/local_job_queue.rb', line 23 def publish(event_path,event) @queue << [event_path, event] end |