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.
7 8 9 10 11 12 13 14 |
# File 'lib/ldclient-rb/polling.rb', line 7 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
16 17 18 |
# File 'lib/ldclient-rb/polling.rb', line 16 def initialized? @initialized.value end |
#start ⇒ Object
20 21 22 23 24 25 |
# File 'lib/ldclient-rb/polling.rb', line 20 def start return @ready unless @started.make_true @config.logger.info { "[LDClient] Initializing polling connection" } create_worker @ready end |
#stop ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/ldclient-rb/polling.rb', line 27 def stop if @stopped.make_true if @worker && @worker.alive? && @worker != Thread.current @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 |