Class: EM::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/em/worker.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Worker

Returns a new instance of Worker.



5
6
7
8
9
# File 'lib/em/worker.rb', line 5

def initialize(options={})
  @task_queue = EM::Queue.new
  @concurrency = options.fetch(:concurrency, 10)
  start
end

Instance Method Details

#enqueue(task = nil, callback = nil, options = {}, &block) ⇒ Object



11
12
13
14
15
# File 'lib/em/worker.rb', line 11

def enqueue(task=nil, callback=nil, options={}, &block)
  task ||= block || Proc.new {}
  @task_queue.push([task, callback, options])
  true
end