Class: Proco::Dispatcher
- Inherits:
-
Object
- Object
- Proco::Dispatcher
- Includes:
- MT::Threaded
- Defined in:
- lib/proco/dispatcher.rb
Instance Method Summary collapse
- #exit ⇒ Object
-
#initialize(proco, thread_pool, block) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
- #push(*items) ⇒ Object
Methods included from MT::Threaded
Methods included from MT::Base
#broadcast, #do_when, #signal, #synchronize, #try_when, #wait_until
Methods included from Logger
Constructor Details
#initialize(proco, thread_pool, block) ⇒ Dispatcher
Returns a new instance of Dispatcher.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/proco/dispatcher.rb', line 8 def initialize proco, thread_pool, block super() @logger, interval, qs, batch, batch_size = proco..values_at :logger, :interval, :queue_size, :batch, :batch_size @queue = if batch && batch_size Proco::Queue::BatchQueue.new(qs, batch_size, interval) elsif batch Proco::Queue::MultiQueue.new(qs, interval) else Proco::Queue::SingleQueue.new(qs, interval) end @pool = thread_pool @block = block spawn do future = items = nil LPS.interval(interval).while { future, items = @queue.take future # JRuby bug }.loop do inner_loop future, items end end end |
Instance Method Details
#exit ⇒ Object
38 39 40 41 |
# File 'lib/proco/dispatcher.rb', line 38 def exit @queue.invalidate super end |
#push(*items) ⇒ Object
34 35 36 |
# File 'lib/proco/dispatcher.rb', line 34 def push *items @queue.push(*items) end |