Class: PgPipeline::Runtime::Notification
- Inherits:
-
Object
- Object
- PgPipeline::Runtime::Notification
- Defined in:
- lib/pg_pipeline/runtime/notification.rb
Instance Method Summary collapse
-
#initialize ⇒ Notification
constructor
A new instance of Notification.
- #signal ⇒ Object
- #signal_all ⇒ Object
- #wait(timeout = nil) ⇒ Object
Constructor Details
#initialize ⇒ Notification
Returns a new instance of Notification.
6 7 8 |
# File 'lib/pg_pipeline/runtime/notification.rb', line 6 def initialize @waiters = [] end |
Instance Method Details
#signal ⇒ Object
19 20 21 22 23 |
# File 'lib/pg_pipeline/runtime/notification.rb', line 19 def signal waiter = @waiters.shift or return false Runtime.wake_dequeued(waiter, self) true end |
#signal_all ⇒ Object
25 26 27 28 29 |
# File 'lib/pg_pipeline/runtime/notification.rb', line 25 def signal_all pending, @waiters = @waiters, [] pending.each { |waiter| Runtime.wake_dequeued(waiter, self) } nil end |
#wait(timeout = nil) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/pg_pipeline/runtime/notification.rb', line 10 def wait(timeout = nil) Runtime.with_waiter(self, @waiters) do |waiter| Runtime.with_timeout(timeout) { Runtime.park(self, waiter) { false } } true rescue TimeoutError false end end |