Skip to content

Updating edge futures -> Promises (preparation for later merge) #522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 68 commits into from
Dec 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
bd1dba6
Rename FutureShortcuts to FutureFactoryMethods
pitr-ch Mar 14, 2016
7b755ad
split completable future construction from future to its own method c…
pitr-ch Mar 14, 2016
a3643a9
move new Futures to core
pitr-ch Mar 14, 2016
03512a8
update documentation
pitr-ch Mar 14, 2016
95fb67c
FutureFactoryMethods can be just FactoryMethods
pitr-ch Mar 14, 2016
f1d2058
methods with block can take arguments which are safly published and p…
pitr-ch Mar 21, 2016
561a57b
promises_spec cleanup
pitr-ch Mar 22, 2016
960c9a1
Promises improvements
pitr-ch Mar 27, 2016
3bcd872
Cooperative cancellation for promises and any other async processing
pitr-ch Mar 27, 2016
c1acd20
Add empty? and clear_if concurrent methods to LockFreeStack
pitr-ch Jun 11, 2016
0bb9203
Cancellation: allow to configure the cancellable event/future
pitr-ch Jun 11, 2016
76e956c
Cancellation unify cancel methods
pitr-ch Jun 11, 2016
53128c3
Fix any methods
pitr-ch Jun 11, 2016
278cdae
Remove bad aliases
pitr-ch Jun 11, 2016
f1cea8b
BlockedPromise always takes an array of futures
pitr-ch Jun 11, 2016
c110154
Add marking Completable module
pitr-ch Jun 11, 2016
8340b14
Memoize wrappers of Completables
pitr-ch Jun 11, 2016
4b00a78
Update promises tests
pitr-ch Jun 11, 2016
97e74ad
Add experimental Throttle
pitr-ch Jun 11, 2016
be0ed75
Keep promisses in edge for now
pitr-ch Jun 11, 2016
334e526
Fix AnySuccessfulFuturePromise
pitr-ch Jun 11, 2016
75b8186
Update examples
pitr-ch Jun 11, 2016
59f9e46
Documentation and hiding constants
pitr-ch Jun 11, 2016
3d2d4c2
New Promises documentation and updates
pitr-ch Jun 13, 2016
0210f7a
fix success vs succeed naming
pitr-ch Jul 29, 2016
da530a8
fix visibility of methods in documentation
pitr-ch Jul 29, 2016
86fd08e
do not call touch when completed, saves CAS
pitr-ch Jul 29, 2016
de57bad
Rename new promises states
pitr-ch Jul 30, 2016
248762b
update primises md documentation
pitr-ch Jul 30, 2016
07510fc
add general constructor
pitr-ch Jul 30, 2016
d6d1dd2
convert rest of the examples to evaluated md
pitr-ch Jul 30, 2016
c1d0dd9
leave _using suffix just for callbacks
pitr-ch Jul 30, 2016
40a4cc3
Allow to insert throttle into chain
pitr-ch Jul 30, 2016
773ad59
fix bad macro usage
pitr-ch Jul 30, 2016
ee511f2
fix headers, add cancellation and throttling to documetnation
pitr-ch Jul 30, 2016
efa9c6e
fix spec
pitr-ch Jul 30, 2016
08b9aad
Remove dependency on logging
pitr-ch Jul 30, 2016
7247700
Remove unnecessary method
pitr-ch Jul 30, 2016
292cc93
Readme update
pitr-ch Nov 5, 2016
ef570a7
Move files where they belong
pitr-ch Nov 5, 2016
38ab132
Update throttle, add conversion methods
pitr-ch Dec 12, 2016
bd38e33
Move cancellation out
pitr-ch Dec 17, 2016
b96e048
Use lock-free-queue in throttling and improve API
pitr-ch Dec 17, 2016
afe15b6
Make resolving of dependent futures independent on blocked_by interna…
pitr-ch Dec 17, 2016
0a85d02
Remove dependency in zip promise on blocked_by
pitr-ch Dec 18, 2016
6bfd19a
Remove blocked_by completely
pitr-ch Dec 20, 2016
6b11145
Eliminate some array allocations
pitr-ch Dec 20, 2016
07c968c
Simplify to_s and inspect
pitr-ch Dec 23, 2016
6d8ad2d
Fix spec error class
pitr-ch Dec 23, 2016
9509164
LockFreeStack fast constructors for 1,2 elements
pitr-ch Dec 23, 2016
001691a
Fix event's state symbol representation
pitr-ch Dec 23, 2016
183a4fc
Deal correctly with multiple exceptions in #exception method
pitr-ch Dec 23, 2016
7e17458
More documentation
pitr-ch Dec 23, 2016
fa5417e
Polishing throttling
pitr-ch Dec 23, 2016
79c835c
Move throttle to its own file
pitr-ch Dec 23, 2016
c3c9a47
Better names for new_blocked methods
pitr-ch Dec 23, 2016
160a457
Few to_s improvements
pitr-ch Dec 23, 2016
6d0bb34
Concurrent::Map#each_pair should return enumerable when no block given
pitr-ch Dec 23, 2016
036b0c4
Update spec to moved throttle
pitr-ch Dec 23, 2016
9d7b3cb
Update dependencies
pitr-ch Dec 23, 2016
41cf14d
More documentation for Throttle and other minor improvmenets
pitr-ch Dec 23, 2016
399d276
Deal with bad executor early
pitr-ch Dec 23, 2016
a0a7702
Remove deadlocking std logger
pitr-ch Dec 24, 2016
b8ec2e3
Prefer spawn! over spawn in actor specs
pitr-ch Dec 24, 2016
eb81fff
avoid "can't be called from trap context" errors in ThreadLocalVar
pitr-ch Dec 24, 2016
456980e
Minor fixes
pitr-ch Dec 24, 2016
a756a70
Documentation updates
pitr-ch Dec 27, 2016
0f33d09
Add Promise::Channel
pitr-ch Dec 27, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
--title=Concurrent Ruby
--template default
--template-path ./yard-template
--default-return undocumented

./lib/**/*.rb
./ext/concurrent_ruby_ext/**/*.c
-
doc/thread_pools.md
doc/promises.out.md
README.md
LICENSE.txt
12 changes: 7 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ gemspec name: 'concurrent-ruby'
gemspec name: 'concurrent-ruby-edge'

group :development do
gem 'rake', '~> 10.4.2'
gem 'rake', '~> 10.0'
gem 'rake-compiler', '~> 0.9.5'
gem 'rake-compiler-dock', '~> 0.4.3'
gem 'gem-compiler', '~> 0.3.0'
gem 'benchmark-ips', '~> 2.2.0'
gem 'benchmark-ips', '~> 2.7'

# documentation
gem 'countloc', '~> 0.4.0', :platforms => :mri, :require => false
gem 'yard', '~> 0.8.7.6', :require => false
gem 'yard', '~> 0.8.0', :require => false
# TODO (pitr-ch 15-Oct-2016): does not work on 1.9.3 anymore
gem 'inch', '~> 0.6.3', :platforms => :mri, :require => false
gem 'redcarpet', '~> 3.3.2', platforms: :mri # understands github markdown
# TODO remove, reports private classes as undocumented
gem 'inch', '~> 0.7.0', :platforms => :mri, :require => false
gem 'redcarpet', '~> 3.3', platforms: :mri # understands github markdown
gem 'md-ruby-eval'
end

group :testing do
Expand Down
66 changes: 28 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,28 @@
[![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
[![Gitter chat](https://img.shields.io/badge/IRC%20(gitter)-devs%20%26%20users-brightgreen.svg)](https://gitter.im/ruby-concurrency/concurrent-ruby)

<table>
<tr>
<td align="left" valign="top">
<p>
Modern concurrency tools for Ruby. Inspired by
<a href="http://www.erlang.org/doc/reference_manual/processes.html">Erlang</a>,
<a href="http://clojure.org/concurrent_programming">Clojure</a>,
<a href="http://akka.io/">Scala</a>,
<a href="http://www.haskell.org/haskellwiki/Applications_and_libraries/Concurrency_and_parallelism#Concurrent_Haskell">Haskell</a>,
<a href="http://blogs.msdn.com/b/dsyme/archive/2010/02/15/async-and-parallel-design-patterns-in-f-part-3-agents.aspx">F#</a>,
<a href="http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx">C#</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/package-summary.html">Java</a>,
and classic concurrency patterns.
</p>
<p>
The design goals of this gem are:
<ul>
<li>Be an 'unopinionated' toolbox that provides useful utilities without debating which is better or why</li>
<li>Remain free of external gem dependencies</li>
<li>Stay true to the spirit of the languages providing inspiration</li>
<li>But implement in a way that makes sense for Ruby</li>
<li>Keep the semantics as idiomatic Ruby as possible</li>
<li>Support features that make sense in Ruby</li>
<li>Exclude features that don't make sense in Ruby</li>
<li>Be small, lean, and loosely coupled</li>
</ul>
</p>
</td>
<td align="right" valign="top">
<img src="https://raw.githubusercontent.com/ruby-concurrency/concurrent-ruby/master/doc/logo/concurrent-ruby-logo-300x300.png"/>
</td>
</tr>
</table>
Modern concurrency tools for Ruby. Inspired by
[Erlang](http://www.erlang.org/doc/reference_manual/processes.html),
[Clojure](http://clojure.org/concurrent_programming),
[Scala](http://akka.io/),
[Haskell](http://www.haskell.org/haskellwiki/Applications_and_libraries/Concurrency_and_parallelism#Concurrent_Haskell),
[F#](http://blogs.msdn.com/b/dsyme/archive/2010/02/15/async-and-parallel-design-patterns-in-f-part-3-agents.aspx),
[C#](http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx),
[Java](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/package-summary.html),
and classic concurrency patterns.

<img src="https://raw.githubusercontent.com/ruby-concurrency/concurrent-ruby/master/doc/logo/concurrent-ruby-logo-300x300.png" align="right" style="margin-left: 20px;" />

The design goals of this gem are:

* Be an 'unopinionated' toolbox that provides useful utilities without debating which is better or why
* Remain free of external gem dependencies
* Stay true to the spirit of the languages providing inspiration
* But implement in a way that makes sense for Ruby
* Keep the semantics as idiomatic Ruby as possible
* Support features that make sense in Ruby
* Exclude features that don't make sense in Ruby
* Be small, lean, and loosely coupled

### Supported Ruby versions

Expand Down Expand Up @@ -127,29 +116,30 @@ These features are under active development and may change frequently. They are
keep backward compatibility (there may also lack tests and documentation). Semantic versions will
be obeyed though. Features developed in `concurrent-ruby-edge` are expected to move to `concurrent-ruby` when final.

* [Actor](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Actor.html):
Implements the Actor Model, where concurrent actors exchange messages.
* [New Future Framework](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Edge/FutureShortcuts.html):
* [Promises Framework](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Promises.html):
Unified implementation of futures and promises which combines features of previous `Future`,
`Promise`, `IVar`, `Event`, `dataflow`, `Delay`, and `TimerTask` into a single framework. It extensively uses the
new synchronization layer to make all the features **non-blocking** and **lock-free**, with the exception of obviously blocking
operations like `#wait`, `#value`. It also offers better performance.
* [Actor](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Actor.html):
Implements the Actor Model, where concurrent actors exchange messages.
* [Channel](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Edge/Channel.html):
Communicating Sequential Processes ([CSP](https://en.wikipedia.org/wiki/Communicating_sequential_processes)).
Functionally equivalent to Go [channels](https://tour.golang.org/concurrency/2) with additional
inspiration from Clojure [core.async](https://clojure.github.io/core.async/).
* [LazyRegister](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/LazyRegister.html)
* [AtomicMarkableReference](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Edge/AtomicMarkableReference.html)
* [LockFreeLinkedSet](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Edge/LockFreeLinkedSet.html)
* [LockFreeStack](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Edge/LockFreeStack.html)
* [LockFreeStack](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/LockFreeStack.html)

#### Statuses:

*Why are these not in core?*

- **Promises Framework** - They are being finalized to be able to be moved to core. They'll deprecate old
implementation.
- **Actor** - Partial documentation and tests; depends on new future/promise framework; stability is good.
- **Channel** - Brand new implementation; partial documentation and tests; stability is good.
- **Future/Promise Framework** - API changes; partial documentation and tests; stability is good.
- **LazyRegister** - Missing documentation and tests.
- **AtomicMarkableReference, LockFreeLinkedSet, LockFreeStack** - Need real world battle testing.

Expand Down
12 changes: 0 additions & 12 deletions doc/future-promise.md

This file was deleted.

61 changes: 61 additions & 0 deletions doc/promises-main.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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:

- Process tasks asynchronously
- Chain, branch, and zip the asynchronous tasks together
- Therefore, to create directed acyclic graph (hereafter DAG) of tasks
- Create delayed tasks (or delayed DAG of tasks)
- Create scheduled tasks (or delayed DAG of tasks)
- Deal with errors through rejections
- Reduce danger of deadlocking
- Control the concurrency level of tasks
- Simulate thread-like processing without occupying threads
- It allows to create tens of thousands simulations on one thread
pool
- It works well on all Ruby implementations
- Use actors to maintain isolated states and to seamlessly combine
it with promises
- Build parallel processing stream system with back
pressure (parts, which are not keeping up, signal to the other parts of the
system to slow down).

**The guide is best place to start with promises, see**
**{file:doc/promises.out.md}.**

# Main classes

The main public user-facing classes are {Concurrent::Promises::Event} and
{Concurrent::Promises::Future} which share common ancestor
{Concurrent::Promises::AbstractEventFuture}.

**{Concurrent::Promises::AbstractEventFuture}:**
> {include:Concurrent::Promises::AbstractEventFuture}

**{Concurrent::Promises::Event}:**
> {include:Concurrent::Promises::Event}

**{Concurrent::Promises::Future}:**
> {include:Concurrent::Promises::Future}

Loading