Class: Wonkavision::LocalJobQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/wonkavision/local_job_queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options={})
  worker_count = options[: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

#queueObject (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