Class: Concurrent::Promises::ResolvableEvent

Inherits:
Event show all
Includes:
Resolvable
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/promises.rb

Overview

A Event which can be resolved by user.

Instance Method Summary collapse

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

Methods inherited from Synchronization::Object

atomic_attribute?, atomic_attributes, attr_atomic, attr_volatile, ensure_safe_initialization_when_final_fields_are_present, #initialize, safe_initialization!, safe_initialization?

Instance Method Details

#resolve(raise_on_reassign = true, reserved = false) ⇒ self, false

Makes the event resolved, which triggers all dependent futures.

Parameters:

  • raise_on_reassign (Boolean) (defaults to: true)

    should method raise exception if already resolved

  • reserved (true, false) (defaults to: false)

    Set to true if the resolvable is #reserved by you, marks resolution of reserved resolvable events and futures explicitly. Advanced feature, ignore unless you use Resolvable#reserve from edge.

Returns:

  • (self, false)

    false is returner when raise_on_reassign is false and the receiver is already resolved.



1313
1314
1315
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/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, ...

Behaves as AbstractEventFuture#wait but has one additional optional argument resolve_on_timeout.

Parameters:

  • resolve_on_timeout (true, false) (defaults to: false)

    If it times out and the argument is true it will also resolve the event.

Returns:

  • (self, true, false)

See Also:



1331
1332
1333
1334
1335
1336
1337
1338
1339
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/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_resolvableEvent

Creates new event wrapping receiver, effectively hiding the resolve method.

Returns:



1320
1321
1322
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/promises.rb', line 1320

def with_hidden_resolvable
  @with_hidden_resolvable ||= EventWrapperPromise.new_blocked_by1(self, @DefaultExecutor).event
end