Class: QuackConcurrency::Waiter Private
- Inherits:
-
Object
- Object
- QuackConcurrency::Waiter
- Defined in:
- lib/quack_concurrency/waiter.rb
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.
Instance Method Summary collapse
- #any_waiting_threads? ⇒ Boolean private
-
#initialize ⇒ Waiter
constructor
private
Creates a new Waiter concurrency tool.
-
#resume_all ⇒ void
private
Resumes all current and future waiting Thread.
-
#resume_all_forever ⇒ void
private
Resumes all current and future waiting Thread.
-
#resume_one ⇒ void
private
Resumes next waiting Thread if one exists.
-
#wait ⇒ void
private
Waits for another Thread to resume the calling Thread.
- #waiting_threads_count ⇒ Object private
Constructor Details
#initialize ⇒ Waiter
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.
Creates a new QuackConcurrency::Waiter concurrency tool.
8 9 10 11 12 |
# File 'lib/quack_concurrency/waiter.rb', line 8 def initialize @condition_variable = UninterruptibleConditionVariable.new @resume_all_forever = false @mutex = ::Mutex.new end |
Instance Method Details
#any_waiting_threads? ⇒ Boolean
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.
14 15 16 |
# File 'lib/quack_concurrency/waiter.rb', line 14 def any_waiting_threads? @condition_variable.any_waiting_threads? end |
#resume_all ⇒ void
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.
This method returns an undefined value.
Resumes all current and future waiting Thread.
20 21 22 23 |
# File 'lib/quack_concurrency/waiter.rb', line 20 def resume_all @condition_variable.broadcast nil end |
#resume_all_forever ⇒ void
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.
This method returns an undefined value.
Resumes all current and future waiting Thread.
27 28 29 30 31 32 33 |
# File 'lib/quack_concurrency/waiter.rb', line 27 def resume_all_forever @mutex.synchronize do @resume_all_forever = true resume_all end nil end |
#resume_one ⇒ void
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.
This method returns an undefined value.
Resumes next waiting Thread if one exists.
37 38 39 40 |
# File 'lib/quack_concurrency/waiter.rb', line 37 def resume_one @condition_variable.signal nil end |
#wait ⇒ void
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.
Will block until resumed.
This method returns an undefined value.
Waits for another Thread to resume the calling Thread.
45 46 47 48 49 50 51 |
# File 'lib/quack_concurrency/waiter.rb', line 45 def wait @mutex.synchronize do return if @resume_all_forever @condition_variable.wait(@mutex) end nil end |
#waiting_threads_count ⇒ 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.
53 54 55 |
# File 'lib/quack_concurrency/waiter.rb', line 53 def waiting_threads_count @condition_variable.waiting_threads_count end |