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
- #wait_until(deadline = nil) ⇒ Object
- #waiting ⇒ 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
22 23 24 25 26 27 28 |
# File 'lib/pg_pipeline/runtime/notification.rb', line 22 def signal while (waiter = @waiters.shift) return true if Runtime.wake_dequeued(waiter, self) end false end |
#signal_all ⇒ Object
30 31 32 33 34 |
# File 'lib/pg_pipeline/runtime/notification.rb', line 30 def signal_all pending, @waiters = @waiters, [] pending.each { |waiter| Runtime.wake_dequeued(waiter, self) } nil end |
#wait(timeout = nil) ⇒ Object
12 13 14 |
# File 'lib/pg_pipeline/runtime/notification.rb', line 12 def wait(timeout = nil) wait_until(Runtime.deadline_for(timeout)) end |
#wait_until(deadline = nil) ⇒ Object
16 17 18 19 20 |
# File 'lib/pg_pipeline/runtime/notification.rb', line 16 def wait_until(deadline = nil) Runtime.with_waiter(self, @waiters) do |waiter| Runtime.park(self, waiter, deadline) { false } end end |
#waiting ⇒ Object
10 |
# File 'lib/pg_pipeline/runtime/notification.rb', line 10 def waiting = @waiters.size |