Class: Concurrent::Promises::ResolvableEvent
- Inherits:
-
Event
- Object
- Synchronization::AbstractObject
- 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, ...
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.
Methods inherited from Event
#any, #delay, #schedule, #to_event, #to_future, #with_default_executor, #zip
Methods inherited from AbstractEventFuture
#chain, #chain_on, #chain_resolvable, #default_executor, #internal_state, #on_resolution, #on_resolution!, #on_resolution_using, #pending?, #resolved?, #state, #to_s, #touch, #with_default_executor
Instance Method Details
#resolve(raise_on_reassign = true, reserved = false) ⇒ self, false
Makes the event resolved, which triggers all dependent futures.
1324 1325 1326 |
# File 'lib/concurrent-ruby/concurrent/promises.rb', line 1324 def resolve(raise_on_reassign = true, reserved = false) resolve_with RESOLVED, raise_on_reassign, reserved end |
#wait(timeout = nil, resolve_on_timeout = false) ⇒ self, ...
Behaves as AbstractEventFuture#wait but has one additional optional argument resolve_on_timeout.
1342 1343 1344 1345 1346 1347 1348 1349 1350 |
# File 'lib/concurrent-ruby/concurrent/promises.rb', line 1342 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.
1331 1332 1333 |
# File 'lib/concurrent-ruby/concurrent/promises.rb', line 1331 def with_hidden_resolvable @with_hidden_resolvable ||= EventWrapperPromise.new_blocked_by1(self, @DefaultExecutor).event end |