Class: Datadog::Core::Semaphore Private
- Inherits:
-
Object
- Object
- Datadog::Core::Semaphore
- 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.
Instance Method Summary collapse
-
#initialize ⇒ Semaphore
constructor
private
A new instance of Semaphore.
- #signal ⇒ Object private
- #wait(timeout = nil) ⇒ Object private
Constructor Details
#initialize ⇒ Semaphore
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.
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
#signal ⇒ 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.
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.
21 22 23 24 25 26 27 28 |
# File 'lib/datadog/core/semaphore.rb', line 21 def wait(timeout = nil) wake_lock.synchronize do # steep specifies that the second argument to wait is of type # ::Time::_Timeout which for some reason is not Numeric and is not # castable from Numeric. wake.wait(wake_lock, timeout) # steep:ignore end end |