Class: LaunchDarkly::PollingProcessor
- Inherits:
-
Object
- Object
- LaunchDarkly::PollingProcessor
- Defined in:
- lib/ldclient-rb/polling.rb
Instance Method Summary collapse
-
#initialize(config, requestor) ⇒ PollingProcessor
constructor
A new instance of PollingProcessor.
- #initialized? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(config, requestor) ⇒ PollingProcessor
Returns a new instance of PollingProcessor.
6 7 8 9 10 11 12 13 |
# File 'lib/ldclient-rb/polling.rb', line 6 def initialize(config, requestor) @config = config @requestor = requestor @initialized = Concurrent::AtomicBoolean.new(false) @started = Concurrent::AtomicBoolean.new(false) @stopped = Concurrent::AtomicBoolean.new(false) @ready = Concurrent::Event.new end |
Instance Method Details
#initialized? ⇒ Boolean
15 16 17 |
# File 'lib/ldclient-rb/polling.rb', line 15 def initialized? @initialized.value end |
#start ⇒ Object
19 20 21 22 23 24 |
# File 'lib/ldclient-rb/polling.rb', line 19 def start return @ready unless @started.make_true @config.logger.info { "[LDClient] Initializing polling connection" } create_worker @ready end |
#stop ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/ldclient-rb/polling.rb', line 26 def stop if @stopped.make_true if @worker && @worker.alive? @worker.run # causes the thread to wake up if it's currently in a sleep @worker.join end @config.logger.info { "[LDClient] Polling connection stopped" } end end |