Class: LaunchDarkly::PollingProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/polling.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


15
16
17
# File 'lib/ldclient-rb/polling.rb', line 15

def initialized?
  @initialized.value
end

#startObject



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

#stopObject



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