123456789_123456789_123456789_123456789_123456789_

Class: Concurrent::Promises::ResolvableEvent

Overview

A Event which can be resolved by user.

Constant Summary

InternalStates - Included

PENDING, RESERVED, RESOLVED

Class Attribute Summary

Class Method Summary

AbstractEventFuture - Inherited

Synchronization::Object - Inherited

.atomic_attribute?, .atomic_attributes,
.attr_atomic

Creates methods for reading and writing to a instance variable with volatile (Java) semantic as .attr_volatile does.

.attr_volatile

Creates methods for reading and writing (as attr_accessor does) to a instance variable with volatile (Java) semantic.

.ensure_safe_initialization_when_final_fields_are_present

For testing purposes, quite slow.

.new

Has to be called by children.

.safe_initialization!, .define_initialize_atomic_fields

Synchronization::AbstractObject - Inherited

Instance Attribute Summary

AbstractEventFuture - Inherited

#pending?

Is it in pending state?

#resolved?

Is it in resolved state?

#touched?

For inspection.

Instance Method Summary

Resolvable - Included

#release,
#reserve

Reserves the event or future, if reserved others are prevented from resolving it.

Event - Inherited

#&

Alias for Event#zip.

#any

Creates a new event which will be resolved when the first of receiver, event_or_future resolves.

#delay

Creates new event dependent on receiver which will not evaluate until touched, see #touch.

#schedule

Creates new event dependent on receiver scheduled to execute on/in intended_time.

#then
#to_event

Returns self, since this is event.

#to_future

Converts event to a future.

#with_default_executor

Crates new object with same class with the executor set as its new default executor.

#zip

Creates a new event or a future which will be resolved when receiver and other are.

#|

Alias for Event#any.

#callback_on_resolution, #rejected_resolution

AbstractEventFuture - Inherited

#chain

Shortcut of #chain_on with default :io executor supplied.

#chain_on

Chains the task to be executed asynchronously on executor after it is resolved.

#chain_resolvable

Resolves the resolvable when receiver is resolved.

#default_executor

Returns default executor.

#inspect
#internal_state,
#on_resolution

Shortcut of #on_resolution_using with default :io executor supplied.

#on_resolution!

Stores the callback to be executed synchronously on resolving thread after it is resolved.

#on_resolution_using

Stores the callback to be executed asynchronously on executor after it is resolved.

#state

Returns its state.

#tangle
#to_s,
#touch

Propagates touch.

#wait

Wait (block the Thread) until receiver is #resolved?.

#with_default_executor

Crates new object with same class with the executor set as its new default executor.

#add_callback, #add_callback_clear_delayed_node, #add_callback_notify_blocked, #async_callback_on_resolution,
#blocks

For inspection.

#call_callback, #call_callbacks, #callback_clear_delayed_node, #callback_notify_blocked,
#callbacks

For inspection.

#compare_and_set_internal_state

Sets the internal_state to new_internal_state if the current internal_state is expected_internal_state.

#internal_state=

Set the internal_state.

#promise

For inspection.

#resolve_with,
#swap_internal_state

Set the internal_state to new_internal_state and return the old internal_state.

#update_internal_state

Updates the internal_state using the block.

#wait_until_resolved,
#waiting_threads

For inspection.

#with_async, #with_hidden_resolvable

Synchronization::Object - Inherited

Synchronization::Volatile - Included

Synchronization::AbstractObject - Inherited

Constructor Details

This class inherits a constructor from Concurrent::Promises::AbstractEventFuture

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 returned when raise_on_reassign is false and the receiver is already resolved.

[ GitHub ]

  
# 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.

Parameters:

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

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

See Also:

[ GitHub ]

  
# 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_resolvableEvent

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

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/promises.rb', line 1331

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