Class: SimpleWorker::Worker
- Inherits:
-
Queue
- Object
- Queue
- SimpleWorker::Worker
- Defined in:
- lib/simple-worker.rb
Instance Method Summary collapse
-
#initialize(num = 1) ⇒ Worker
constructor
A new instance of Worker.
- #push(obj = nil, &block) ⇒ Object
Constructor Details
#initialize(num = 1) ⇒ Worker
Returns a new instance of Worker.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/simple-worker.rb', line 5 def initialize(num = 1) super() @workers = [] num.times do |i| @workers << Thread.start do loop do pop.call(i) end end end end |
Instance Method Details
#push(obj = nil, &block) ⇒ Object
18 19 20 |
# File 'lib/simple-worker.rb', line 18 def push(obj = nil, &block) super(obj || block) end |