Class: Datadog::Core::Semaphore Private

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/core/semaphore.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Semaphore pattern implementation, as described in documentation for ConditionVariable.

API:

  • private

Instance Method Summary collapse

Constructor Details

#initializeSemaphore

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Semaphore.

API:

  • private



10
11
12
13
# File 'lib/datadog/core/semaphore.rb', line 10

def initialize
  @wake_lock = Mutex.new
  @wake = ConditionVariable.new
end

Instance Method Details

#signalObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



15
16
17
18
19
# File 'lib/datadog/core/semaphore.rb', line 15

def signal
  wake_lock.synchronize do
    wake.signal
  end
end

#wait(timeout = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



21
22
23
24
25
# File 'lib/datadog/core/semaphore.rb', line 21

def wait(timeout = nil)
  wake_lock.synchronize do
    wake.wait(wake_lock, timeout)
  end
end