Class: Concurrent::Promises::ResolvableEvent
- Inherits:
-
Event
- Object
- Synchronization::Object
- AbstractEventFuture
- Event
- Concurrent::Promises::ResolvableEvent
- Includes:
- Resolvable
- Defined in:
- lib/concurrent-ruby/concurrent/promises.rb
Overview
A Event which can be resolved by user.
Instance Method Summary collapse
-
#resolve(raise_on_reassign = true, reserved = false) ⇒ self, false
Makes the event resolved, which triggers all dependent futures.
-
#wait(timeout = nil, resolve_on_timeout = false) ⇒ self, true, false
Behaves as AbstractEventFuture#wait but has one additional optional argument resolve_on_timeout.
-
#with_hidden_resolvable ⇒ Event
Creates new event wrapping receiver, effectively hiding the resolve method.
-
#release ⇒ true, false
included
from Resolvable
On successful release of the reservation.
-
#reserve ⇒ true, false
included
from Resolvable
Reserves the event or future, if reserved others are prevented from resolving it.
Instance Method Details
#resolve(raise_on_reassign = true, reserved = false) ⇒ self, false
Makes the event resolved, which triggers all dependent futures.
1313 1314 1315 |
# File 'lib/concurrent-ruby/concurrent/promises.rb', line 1313 def resolve(raise_on_reassign = true, reserved = false) resolve_with RESOLVED, raise_on_reassign, reserved end |
#wait(timeout = nil, resolve_on_timeout = false) ⇒ self, true, false
Behaves as AbstractEventFuture#wait but has one additional optional argument resolve_on_timeout.
1331 1332 1333 1334 1335 1336 1337 1338 1339 |
# File 'lib/concurrent-ruby/concurrent/promises.rb', line 1331 def wait(timeout = nil, resolve_on_timeout = false) super(timeout) or if resolve_on_timeout # if it fails to resolve it was resolved in the meantime # so return true as if there was no timeout !resolve(false) else false end end |
#with_hidden_resolvable ⇒ Event
Creates new event wrapping receiver, effectively hiding the resolve method.
1320 1321 1322 |
# File 'lib/concurrent-ruby/concurrent/promises.rb', line 1320 def with_hidden_resolvable @with_hidden_resolvable ||= EventWrapperPromise.new_blocked_by1(self, @DefaultExecutor).event end |
#release ⇒ true, false Originally defined in module Resolvable
Returns on successful release of the reservation.
#reserve ⇒ true, false Originally defined in module Resolvable
Reserves the event or future, if reserved others are prevented from resolving it. Advanced feature. Be careful about the order of reservation to avoid deadlocks, the method blocks if the future or event is already reserved until it is released or resolved.