A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html below:

Module: Concurrent::Promises — Concurrent Ruby

Promises is a new framework unifying former tools Concurrent::Future, Concurrent::Promise, Concurrent::IVar, Concurrent::Event, Concurrent.dataflow, Delay, and TimerTask of concurrent-ruby. It extensively uses the new synchronization layer to make all the methods lock-free (with the exception of obviously blocking operations like #wait, #value, etc.). As a result it lowers danger of deadlocking and offers better performance.

It provides similar tools as other promise libraries do, users coming from other languages and other promise libraries will find the same tools here (probably named differently though). The naming conventions were borrowed heavily from JS promises.

This framework, however, is not just a re-implementation of other promise library, it draws inspiration from many other promise libraries, adds new ideas, and is integrated with other abstractions like actors and channels.

Therefore it is likely that user will find a suitable solution for a problem in this framework. If the problem is simple user can pick one suitable abstraction, e.g. just promises or actors. If the problem is complex user can combine parts (promises, channels, actors) which were designed to work together well to a solution. Rather than having to combine fragilely independent tools.

This framework allows its users to:

The guide is best place to start with promises.

Main classes

The main public user-facing classes are Event and Future which share common ancestor AbstractEventFuture.

AbstractEventFuture:

Common ancestor of Event and Future classes, many shared methods are defined here.

Event:

Represents an event which will happen in future (will be resolved). The event is either pending or resolved. It should be always resolved. Use Future to communicate rejections and cancellation.

Future:

Represents a value which will become available in future. May reject with a reason instead, e.g. when the tasks raises an exception.

Class Method Details .any_event_on(default_executor, *futures_and_or_events) ⇒ Event Originally defined in module FactoryMethods

Creates a new event which becomes resolved after the first futures_and_or_events resolves. If resolved it does not propagate AbstractEventFuture#touch, leaving delayed futures un-executed if they are not required any more.

.any_fulfilled_future_on(default_executor, *futures_and_or_events) ⇒ Future Originally defined in module FactoryMethods

Creates a new future which is resolved after the first futures_and_or_events is fulfilled. Its result equals the result of the first resolved future or if all futures_and_or_events reject, it has reason of the last rejected future. If resolved it does not propagate AbstractEventFuture#touch, leaving delayed futures un-executed if they are not required any more. If event is supplied, which does not have value and can be only resolved, it's represented as :fulfilled with value nil.

.any_resolved_future(*futures_and_or_events) ⇒ Future Also known as: any Originally defined in module FactoryMethods .any_resolved_future_on(default_executor, *futures_and_or_events) ⇒ Future Originally defined in module FactoryMethods

Creates a new future which is resolved after the first futures_and_or_events is resolved. Its result equals the result of the first resolved future. If resolved it does not propagate AbstractEventFuture#touch, leaving delayed futures un-executed if they are not required any more. If event is supplied, which does not have value and can be only resolved, it's represented as :fulfilled with value nil.

.default_executor ⇒ Executor, :io, :fast Originally defined in module FactoryMethods::Configuration

Returns the executor which is used when none is supplied to a factory method. The method can be overridden in the receivers of include FactoryMethod.

#delay_on(default_executor, *args) {|*args| ... } ⇒ Future #delay_on(default_executor) ⇒ Event Originally defined in module FactoryMethods

Creates a new event or future which is resolved only after it is touched, see AbstractEventFuture#touch.

.fulfilled_future(value, default_executor = self.default_executor) ⇒ Future Originally defined in module FactoryMethods

Creates a resolved future which will be fulfilled with the given value.

.future_on(default_executor, *args) {|*args| ... } ⇒ Future Originally defined in module FactoryMethods

Constructs a new Future which will be resolved after block is evaluated on default executor. Evaluation begins immediately.

#make_future(nil, default_executor = self.default_executor) ⇒ Event #make_future(a_future, default_executor = self.default_executor) ⇒ Future #make_future(an_event, default_executor = self.default_executor) ⇒ Event #make_future(exception, default_executor = self.default_executor) ⇒ Future #make_future(value, default_executor = self.default_executor) ⇒ Future Originally defined in module FactoryMethods

General constructor. Behaves differently based on the argument's type. It's provided for convenience but it's better to be explicit.

.rejected_future(reason, default_executor = self.default_executor) ⇒ Future Originally defined in module FactoryMethods

Creates a resolved future which will be rejected with the given reason.

.resolved_event(default_executor = self.default_executor) ⇒ Event Originally defined in module FactoryMethods .resolved_future(fulfilled, value, reason, default_executor = self.default_executor) ⇒ Future Originally defined in module FactoryMethods

Creates a resolved future with will be either fulfilled with the given value or rejected with the given reason.

#schedule_on(default_executor, intended_time, *args) {|*args| ... } ⇒ Future #schedule_on(default_executor, intended_time) ⇒ Event Originally defined in module FactoryMethods

Creates a new event or future which is resolved in intended_time.

.zip_events_on(default_executor, *futures_and_or_events) ⇒ Event Originally defined in module FactoryMethods

Creates a new event which is resolved after all futures_and_or_events are resolved. (Future is resolved when fulfilled or rejected.)

.zip_futures(*futures_and_or_events) ⇒ Future Also known as: zip Originally defined in module FactoryMethods .zip_futures_on(default_executor, *futures_and_or_events) ⇒ Future Originally defined in module FactoryMethods

Creates a new future which is resolved after all futures_and_or_events are resolved. Its value is an array of zipped future values. Its reason is an array of reasons for rejection. If there is an error it rejects. If event is supplied, which does not have value and can be only resolved, it's represented as :fulfilled with value nil.

.zip_futures_over(enumerable, &future_factory) ⇒ Future Originally defined in module FactoryMethods Note:

Edge Features are under active development and may change frequently.

Shortcut of #zip_futures_over_on with default :io executor supplied.

.zip_futures_over_on(default_executor, enumerable) {|element| ... } ⇒ Future Originally defined in module FactoryMethods Note:

Edge Features are under active development and may change frequently.

Creates new future which is resolved after all the futures created by future_factory from enumerable elements are resolved. Simplified it does: zip(*enumerable.map { |e| future e, &future_factory })


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4