123456789_123456789_123456789_123456789_123456789_

Promises is a new framework unifying former tools Future, Promise, IVar, 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 Promises::Event and Promises::Future which share common ancestor Promises::AbstractEventFuture.

Promises::AbstractEventFuture:

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

Promises::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.

Promises::Future:

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