Sha256: c715dee8ad15719e13acfd47f826b33876ea1765fcc81f31d89289fb5a281f46
Contents?: true
Size: 988 Bytes
Versions: 2
Compression:
Stored size: 988 Bytes
Contents
module Rpush module Daemon class DispatcherLoop include Reflectable WAKEUP = :wakeup def initialize(queue, dispatcher) @queue = queue @dispatcher = dispatcher end def start @thread = Thread.new do loop do dispatch break if @stop end Rpush::Daemon.store.release_connection end end def stop @stop = true end def wakeup @queue.push(WAKEUP) if @thread end def wait @thread.join if @thread @dispatcher.cleanup end protected def dispatch notification, batch = @queue.pop return if notification == WAKEUP begin @dispatcher.dispatch(notification, batch) rescue StandardError => e Rpush.logger.error(e) reflect(:error, e) ensure batch.notification_dispatched end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rpush-1.0.0-java | lib/rpush/daemon/dispatcher_loop.rb |
rpush-1.0.0 | lib/rpush/daemon/dispatcher_loop.rb |