Class: Rpush::Daemon::Feeder
Class Attribute Summary collapse
Class Method Summary
collapse
reflect
Methods included from Loggable
log_debug, log_error, log_info, log_warn
Class Attribute Details
.should_stop ⇒ Object
Returns the value of attribute should_stop.
39
40
41
|
# File 'lib/rpush/daemon/feeder.rb', line 39
def should_stop
@should_stop
end
|
Class Method Details
.enqueue_notifications ⇒ Object
.feed_all ⇒ Object
42
43
44
|
# File 'lib/rpush/daemon/feeder.rb', line 42
def self.feed_all
enqueue_notifications until Rpush::Daemon.store.pending_delivery_count == 0
end
|
.feed_forever ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/rpush/daemon/feeder.rb', line 46
def self.feed_forever
loop do
enqueue_notifications
interruptible_sleeper.sleep(Rpush.config.push_poll)
return if should_stop
end
end
|
.interruptible_sleeper ⇒ Object
64
65
66
|
# File 'lib/rpush/daemon/feeder.rb', line 64
def self.interruptible_sleeper
@interruptible_sleeper ||= InterruptibleSleep.new
end
|
.start(push_mode = false) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/rpush/daemon/feeder.rb', line 7
def self.start(push_mode = false)
self.should_stop = false
@thread = Thread.new do
push_mode ? feed_all : feed_forever
Rpush::Daemon.store.release_connection
end
@thread.join
rescue StandardError => e
log_error(e)
reflect(:error, e)
ensure
@thread = nil
end
|
.stop ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/rpush/daemon/feeder.rb', line 23
def self.stop
self.should_stop = true
interruptible_sleeper.stop
@thread.join if @thread
rescue StandardError => e
log_error(e)
reflect(:error, e)
ensure
@thread = nil
end
|
.wakeup ⇒ Object
34
35
36
|
# File 'lib/rpush/daemon/feeder.rb', line 34
def self.wakeup
interruptible_sleeper.stop
end
|