Class: Flagstack::Poller

Inherits:
Object
  • Object
show all
Defined in:
lib/flagstack/poller.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


26
27
28
# File 'lib/flagstack/poller.rb', line 26

def running?
  @running && @thread&.alive?
end

#startObject



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

#stopObject



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