Skip to content

Commit ad52e28

Browse files
author
Petr Chalupa
authored
Merge pull request #522 from pitr-ch/futures
Updating edge futures -> Promises (preparation for later merge)
2 parents 7de851c + 0f33d09 commit ad52e28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+5682
-2670
lines changed

.yardopts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
--title=Concurrent Ruby
66
--template default
77
--template-path ./yard-template
8+
--default-return undocumented
89

910
./lib/**/*.rb
1011
./ext/concurrent_ruby_ext/**/*.c
1112
-
1213
doc/thread_pools.md
14+
doc/promises.out.md
1315
README.md
1416
LICENSE.txt

Gemfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ gemspec name: 'concurrent-ruby'
44
gemspec name: 'concurrent-ruby-edge'
55

66
group :development do
7-
gem 'rake', '~> 10.4.2'
7+
gem 'rake', '~> 10.0'
88
gem 'rake-compiler', '~> 0.9.5'
99
gem 'rake-compiler-dock', '~> 0.4.3'
1010
gem 'gem-compiler', '~> 0.3.0'
11-
gem 'benchmark-ips', '~> 2.2.0'
11+
gem 'benchmark-ips', '~> 2.7'
1212

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

2123
group :testing do

README.md

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,28 @@
99
[![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
1010
[![Gitter chat](https://img.shields.io/badge/IRC%20(gitter)-devs%20%26%20users-brightgreen.svg)](https://gitter.im/ruby-concurrency/concurrent-ruby)
1111

12-
<table>
13-
<tr>
14-
<td align="left" valign="top">
15-
<p>
16-
Modern concurrency tools for Ruby. Inspired by
17-
<a href="http://www.erlang.org/doc/reference_manual/processes.html">Erlang</a>,
18-
<a href="http://clojure.org/concurrent_programming">Clojure</a>,
19-
<a href="http://akka.io/">Scala</a>,
20-
<a href="http://www.haskell.org/haskellwiki/Applications_and_libraries/Concurrency_and_parallelism#Concurrent_Haskell">Haskell</a>,
21-
<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>,
22-
<a href="http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx">C#</a>,
23-
<a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/package-summary.html">Java</a>,
24-
and classic concurrency patterns.
25-
</p>
26-
<p>
27-
The design goals of this gem are:
28-
<ul>
29-
<li>Be an 'unopinionated' toolbox that provides useful utilities without debating which is better or why</li>
30-
<li>Remain free of external gem dependencies</li>
31-
<li>Stay true to the spirit of the languages providing inspiration</li>
32-
<li>But implement in a way that makes sense for Ruby</li>
33-
<li>Keep the semantics as idiomatic Ruby as possible</li>
34-
<li>Support features that make sense in Ruby</li>
35-
<li>Exclude features that don't make sense in Ruby</li>
36-
<li>Be small, lean, and loosely coupled</li>
37-
</ul>
38-
</p>
39-
</td>
40-
<td align="right" valign="top">
41-
<img src="https://raw.githubusercontent.com/ruby-concurrency/concurrent-ruby/master/doc/logo/concurrent-ruby-logo-300x300.png"/>
42-
</td>
43-
</tr>
44-
</table>
12+
Modern concurrency tools for Ruby. Inspired by
13+
[Erlang](http://www.erlang.org/doc/reference_manual/processes.html),
14+
[Clojure](http://clojure.org/concurrent_programming),
15+
[Scala](http://akka.io/),
16+
[Haskell](http://www.haskell.org/haskellwiki/Applications_and_libraries/Concurrency_and_parallelism#Concurrent_Haskell),
17+
[F#](http://blogs.msdn.com/b/dsyme/archive/2010/02/15/async-and-parallel-design-patterns-in-f-part-3-agents.aspx),
18+
[C#](http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx),
19+
[Java](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/package-summary.html),
20+
and classic concurrency patterns.
21+
22+
<img src="https://raw.githubusercontent.com/ruby-concurrency/concurrent-ruby/master/doc/logo/concurrent-ruby-logo-300x300.png" align="right" style="margin-left: 20px;" />
23+
24+
The design goals of this gem are:
25+
26+
* Be an 'unopinionated' toolbox that provides useful utilities without debating which is better or why
27+
* Remain free of external gem dependencies
28+
* Stay true to the spirit of the languages providing inspiration
29+
* But implement in a way that makes sense for Ruby
30+
* Keep the semantics as idiomatic Ruby as possible
31+
* Support features that make sense in Ruby
32+
* Exclude features that don't make sense in Ruby
33+
* Be small, lean, and loosely coupled
4534

4635
### Supported Ruby versions
4736

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

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

146135
#### Statuses:
147136

148137
*Why are these not in core?*
149138

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

doc/future-promise.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

doc/promises-main.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Promises is a new framework unifying former tools `Concurrent::Future`,
2+
`Concurrent::Promise`, `Concurrent::IVar`, `Concurrent::Event`,
3+
`Concurrent.dataflow`, `Delay`, and `TimerTask` of concurrent-ruby. It
4+
extensively uses the new synchronization layer to make all the methods
5+
*lock-free* (with the exception of obviously blocking operations like `#wait`,
6+
`#value`, etc.). As a result it lowers danger of deadlocking and offers
7+
better performance.
8+
9+
It provides similar tools as other promise libraries do, users coming from
10+
other languages and other promise libraries will find the same tools here
11+
(probably named differently though). The naming conventions were borrowed
12+
heavily from JS promises.
13+
14+
This framework, however, is not just a re-implementation of other promise
15+
library, it draws inspiration from many other promise libraries, adds new
16+
ideas, and is integrated with other abstractions like actors and channels.
17+
18+
Therefore it is likely that user will find a suitable solution for a problem in
19+
this framework. If the problem is simple user can pick one suitable
20+
abstraction, e.g. just promises or actors. If the problem is complex user can
21+
combine parts (promises, channels, actors) which were designed to work together
22+
well to a solution. Rather than having to combine fragilely independent tools.
23+
24+
This framework allows its users to:
25+
26+
- Process tasks asynchronously
27+
- Chain, branch, and zip the asynchronous tasks together
28+
- Therefore, to create directed acyclic graph (hereafter DAG) of tasks
29+
- Create delayed tasks (or delayed DAG of tasks)
30+
- Create scheduled tasks (or delayed DAG of tasks)
31+
- Deal with errors through rejections
32+
- Reduce danger of deadlocking
33+
- Control the concurrency level of tasks
34+
- Simulate thread-like processing without occupying threads
35+
- It allows to create tens of thousands simulations on one thread
36+
pool
37+
- It works well on all Ruby implementations
38+
- Use actors to maintain isolated states and to seamlessly combine
39+
it with promises
40+
- Build parallel processing stream system with back
41+
pressure (parts, which are not keeping up, signal to the other parts of the
42+
system to slow down).
43+
44+
**The guide is best place to start with promises, see**
45+
**{file:doc/promises.out.md}.**
46+
47+
# Main classes
48+
49+
The main public user-facing classes are {Concurrent::Promises::Event} and
50+
{Concurrent::Promises::Future} which share common ancestor
51+
{Concurrent::Promises::AbstractEventFuture}.
52+
53+
**{Concurrent::Promises::AbstractEventFuture}:**
54+
> {include:Concurrent::Promises::AbstractEventFuture}
55+
56+
**{Concurrent::Promises::Event}:**
57+
> {include:Concurrent::Promises::Event}
58+
59+
**{Concurrent::Promises::Future}:**
60+
> {include:Concurrent::Promises::Future}
61+

0 commit comments

Comments
 (0)