Class: Flagstack::Poller
- Inherits:
-
Object
- Object
- Flagstack::Poller
- Defined in:
- lib/flagstack/poller.rb
Instance Method Summary collapse
-
#initialize(synchronizer, config) ⇒ Poller
constructor
A new instance of Poller.
- #running? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(synchronizer, config) ⇒ Poller
Returns a new instance of Poller.
3 4 5 6 7 8 9 |
# File 'lib/flagstack/poller.rb', line 3 def initialize(synchronizer, config) @synchronizer = synchronizer @config = config @running = false @thread = nil @pid = Process.pid end |
Instance Method Details
#running? ⇒ Boolean
26 27 28 |
# File 'lib/flagstack/poller.rb', line 26 def running? @running && @thread&.alive? end |
#start ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/flagstack/poller.rb', line 11 def start return if @running @running = true @thread = Thread.new { run } @thread.abort_on_exception = false end |
#stop ⇒ Object
19 20 21 22 23 24 |
# File 'lib/flagstack/poller.rb', line 19 def stop @running = false @thread&.wakeup rescue nil @thread&.join(2) @thread = nil end |