concurrent-ruby-edge 0.3.1 → 0.4.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +429 -0
- data/{LICENSE.txt → LICENSE.md} +2 -0
- data/README.md +203 -105
- data/{lib → lib-edge}/concurrent/actor/behaviour/abstract.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/behaviour/awaits.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/behaviour/buffer.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/behaviour/errors_on_unknown_message.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/behaviour/executes_context.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/behaviour/linking.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/behaviour/pausing.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/behaviour/removes_child.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/behaviour/sets_results.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/behaviour/supervising.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/behaviour/termination.rb +1 -1
- data/{lib → lib-edge}/concurrent/actor/behaviour.rb +1 -1
- data/{lib → lib-edge}/concurrent/actor/context.rb +1 -1
- data/{lib → lib-edge}/concurrent/actor/core.rb +2 -1
- data/{lib → lib-edge}/concurrent/actor/default_dead_letter_handler.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/envelope.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/errors.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/internal_delegations.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/public_delegations.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/reference.rb +1 -1
- data/{lib → lib-edge}/concurrent/actor/root.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/type_check.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/utils/ad_hoc.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/utils/balancer.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/utils/broadcast.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/utils/pool.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor/utils.rb +0 -0
- data/{lib → lib-edge}/concurrent/actor.rb +9 -5
- data/{lib → lib-edge}/concurrent/channel/buffer/base.rb +14 -14
- data/{lib → lib-edge}/concurrent/channel/buffer/buffered.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/buffer/dropping.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/buffer/sliding.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/buffer/ticker.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/buffer/timer.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/buffer/unbuffered.rb +1 -1
- data/{lib → lib-edge}/concurrent/channel/buffer.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/selector/after_clause.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/selector/default_clause.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/selector/error_clause.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/selector/put_clause.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/selector/take_clause.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/selector.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel/tick.rb +0 -0
- data/{lib → lib-edge}/concurrent/channel.rb +2 -1
- data/{lib → lib-edge}/concurrent/edge/cancellation.rb +5 -4
- data/{lib → lib-edge}/concurrent/edge/lock_free_linked_set/node.rb +2 -2
- data/{lib → lib-edge}/concurrent/edge/lock_free_linked_set/window.rb +0 -0
- data/{lib → lib-edge}/concurrent/edge/lock_free_linked_set.rb +8 -7
- data/{lib → lib-edge}/concurrent/edge/lock_free_queue.rb +0 -0
- data/{lib → lib-edge}/concurrent/edge/old_channel_integration.rb +0 -0
- data/{lib → lib-edge}/concurrent/edge/processing_actor.rb +3 -3
- data/lib-edge/concurrent/edge/promises.rb +178 -0
- data/{lib → lib-edge}/concurrent/edge/throttle.rb +24 -15
- data/lib-edge/concurrent/edge.rb +21 -0
- data/lib-edge/concurrent/lazy_register.rb +83 -0
- data/{lib → lib-edge}/concurrent-edge.rb +0 -4
- metadata +71 -70
- data/lib/concurrent/edge/atomic_markable_reference.rb +0 -184
- data/lib/concurrent/edge/lock_free_stack.rb +0 -126
- data/lib/concurrent/edge/promises.rb +0 -2111
data/README.md
CHANGED
@@ -3,9 +3,6 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/concurrent-ruby.svg)](http://badge.fury.io/rb/concurrent-ruby)
|
4
4
|
[![Build Status](https://travis-ci.org/ruby-concurrency/concurrent-ruby.svg?branch=master)](https://travis-ci.org/ruby-concurrency/concurrent-ruby)
|
5
5
|
[![Build status](https://ci.appveyor.com/api/projects/status/iq8aboyuu3etad4w?svg=true)](https://ci.appveyor.com/project/rubyconcurrency/concurrent-ruby)
|
6
|
-
[![Code Climate](https://codeclimate.com/github/ruby-concurrency/concurrent-ruby.svg)](https://codeclimate.com/github/ruby-concurrency/concurrent-ruby)
|
7
|
-
[![Inline docs](http://inch-ci.org/github/ruby-concurrency/concurrent-ruby.svg)](http://inch-ci.org/github/ruby-concurrency/concurrent-ruby)
|
8
|
-
[![Dependency Status](https://gemnasium.com/ruby-concurrency/concurrent-ruby.svg)](https://gemnasium.com/ruby-concurrency/concurrent-ruby)
|
9
6
|
[![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
|
10
7
|
[![Gitter chat](https://img.shields.io/badge/IRC%20(gitter)-devs%20%26%20users-brightgreen.svg)](https://gitter.im/ruby-concurrency/concurrent-ruby)
|
11
8
|
|
@@ -19,129 +16,223 @@ Modern concurrency tools for Ruby. Inspired by
|
|
19
16
|
[Java](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/package-summary.html),
|
20
17
|
and classic concurrency patterns.
|
21
18
|
|
22
|
-
<img src="https://raw.githubusercontent.com/ruby-concurrency/concurrent-ruby/master/
|
19
|
+
<img src="https://raw.githubusercontent.com/ruby-concurrency/concurrent-ruby/master/docs-source/logo/concurrent-ruby-logo-300x300.png" align="right" style="margin-left: 20px;" />
|
23
20
|
|
24
21
|
The design goals of this gem are:
|
25
22
|
|
26
|
-
*
|
27
|
-
|
28
|
-
*
|
29
|
-
*
|
30
|
-
*
|
31
|
-
*
|
32
|
-
*
|
33
|
-
*
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
23
|
+
* Be an 'unopinionated' toolbox that provides useful utilities without debating which is better
|
24
|
+
or why
|
25
|
+
* Remain free of external gem dependencies
|
26
|
+
* Stay true to the spirit of the languages providing inspiration
|
27
|
+
* But implement in a way that makes sense for Ruby
|
28
|
+
* Keep the semantics as idiomatic Ruby as possible
|
29
|
+
* Support features that make sense in Ruby
|
30
|
+
* Exclude features that don't make sense in Ruby
|
31
|
+
* Be small, lean, and loosely coupled
|
32
|
+
* Thread-safety
|
33
|
+
* Backward compatibility
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
**This gem depends on
|
38
|
+
[contributions](https://github.com/ruby-concurrency/concurrent-ruby/graphs/contributors) and we
|
39
|
+
appreciate your help. Would you like to contribute? Great! Have a look at
|
40
|
+
[issues with `looking-for-contributor` label](https://github.com/ruby-concurrency/concurrent-ruby/issues?q=is%3Aissue+is%3Aopen+label%3Alooking-for-contributor).** And if you pick something up let us know on the issue.
|
40
41
|
|
41
42
|
## Thread Safety
|
42
43
|
|
43
|
-
*Concurrent Ruby makes the strongest thread safety guarantees of any Ruby concurrency
|
44
|
+
*Concurrent Ruby makes one of the strongest thread safety guarantees of any Ruby concurrency
|
45
|
+
library, providing consistent behavior and guarantees on all three of the main Ruby interpreters
|
46
|
+
(MRI/CRuby, JRuby, and Rubinius).*
|
47
|
+
|
48
|
+
Every abstraction in this library is thread safe. Specific thread safety guarantees are documented
|
49
|
+
with each abstraction.
|
44
50
|
|
45
|
-
|
51
|
+
It is critical to remember, however, that Ruby is a language of mutable references. *No*
|
52
|
+
concurrency library for Ruby can ever prevent the user from making thread safety mistakes (such as
|
53
|
+
sharing a mutable object between threads and modifying it on both threads) or from creating
|
54
|
+
deadlocks through incorrect use of locks. All the library can do is provide safe abstractions which
|
55
|
+
encourage safe practices. Concurrent Ruby provides more safe concurrency abstractions than any
|
56
|
+
other Ruby library, many of which support the mantra of
|
57
|
+
["Do not communicate by sharing memory; instead, share memory by communicating"](https://blog.golang.org/share-memory-by-communicating).
|
58
|
+
Concurrent Ruby is also the only Ruby library which provides a full suite of thread safe and
|
59
|
+
immutable variable types and data structures.
|
46
60
|
|
47
|
-
|
61
|
+
We've also initiated discussion to document [memory model](docs-source/synchronization.md) of Ruby which
|
62
|
+
would provide consistent behaviour and guarantees on all three of the main Ruby interpreters
|
63
|
+
(MRI/CRuby, JRuby, Rubinius, TruffleRuby).
|
48
64
|
|
49
65
|
## Features & Documentation
|
50
66
|
|
51
|
-
The primary site for documentation is the automatically generated
|
67
|
+
**The primary site for documentation is the automatically generated
|
68
|
+
[API documentation](http://ruby-concurrency.github.io/concurrent-ruby/index.html) which is up to
|
69
|
+
date with latest release.** This readme matches the master so may contain new stuff not yet
|
70
|
+
released.
|
71
|
+
|
72
|
+
We also have a [IRC (gitter)](https://gitter.im/ruby-concurrency/concurrent-ruby).
|
73
|
+
|
74
|
+
### Versioning
|
75
|
+
|
76
|
+
* `concurrent-ruby` uses [Semantic Versioning](http://semver.org/)
|
77
|
+
* `concurrent-ruby-ext` has always same version as `concurrent-ruby`
|
78
|
+
* `concurrent-ruby-edge` will always be 0.y.z therefore following
|
79
|
+
[point 4](http://semver.org/#spec-item-4) applies *"Major version zero
|
80
|
+
(0.y.z) is for initial development. Anything may change at any time. The
|
81
|
+
public API should not be considered stable."* However we additionally use
|
82
|
+
following rules:
|
83
|
+
* Minor version increment means incompatible changes were made
|
84
|
+
* Patch version increment means only compatible changes were made
|
52
85
|
|
53
|
-
We also have a [mailing list](http://groups.google.com/group/concurrent-ruby) and [IRC (gitter)](https://gitter.im/ruby-concurrency/concurrent-ruby).
|
54
86
|
|
55
87
|
#### General-purpose Concurrency Abstractions
|
56
88
|
|
57
|
-
*
|
58
|
-
|
59
|
-
|
60
|
-
*
|
61
|
-
|
62
|
-
*
|
89
|
+
* [Async](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Async.html):
|
90
|
+
A mixin module that provides simple asynchronous behavior to a class. Loosely based on Erlang's
|
91
|
+
[gen_server](http://www.erlang.org/doc/man/gen_server.html).
|
92
|
+
* [ScheduledTask](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ScheduledTask.html):
|
93
|
+
Like a Future scheduled for a specific future time.
|
94
|
+
* [TimerTask](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/TimerTask.html):
|
95
|
+
A Thread that periodically wakes up to perform work at regular intervals.
|
96
|
+
* [Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html):
|
97
|
+
Unified implementation of futures and promises which combines features of previous `Future`,
|
98
|
+
`Promise`, `IVar`, `Event`, `dataflow`, `Delay`, and (partially) `TimerTask` into a single
|
99
|
+
framework. It extensively uses the new synchronization layer to make all the features
|
100
|
+
**non-blocking** and **lock-free**, with the exception of obviously blocking operations like
|
101
|
+
`#wait`, `#value`. It also offers better performance.
|
63
102
|
|
64
103
|
#### Thread-safe Value Objects, Structures, and Collections
|
65
104
|
|
66
105
|
Collection classes that were originally part of the (deprecated) `thread_safe` gem:
|
67
106
|
|
68
|
-
*
|
69
|
-
|
70
|
-
*
|
71
|
-
|
107
|
+
* [Array](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Array.html) A thread-safe
|
108
|
+
subclass of Ruby's standard [Array](http://ruby-doc.org/core-2.2.0/Array.html).
|
109
|
+
* [Hash](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Hash.html) A thread-safe
|
110
|
+
subclass of Ruby's standard [Hash](http://ruby-doc.org/core-2.2.0/Hash.html).
|
111
|
+
* [Set](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Set.html) A thread-safe
|
112
|
+
subclass of Ruby's standard [Set](http://ruby-doc.org/stdlib-2.4.0/libdoc/set/rdoc/Set.html).
|
113
|
+
* [Map](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Map.html) A hash-like object
|
114
|
+
that should have much better performance characteristics, especially under high concurrency,
|
115
|
+
than `Concurrent::Hash`.
|
116
|
+
* [Tuple](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Tuple.html) A fixed size
|
117
|
+
array with volatile (synchronized, thread safe) getters/setters.
|
72
118
|
|
73
119
|
Value objects inspired by other languages:
|
74
120
|
|
75
|
-
*
|
76
|
-
|
77
|
-
|
121
|
+
* [Maybe](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Maybe.html) A thread-safe,
|
122
|
+
immutable object representing an optional value, based on
|
123
|
+
[Haskell Data.Maybe](https://hackage.haskell.org/package/base-4.2.0.1/docs/Data-Maybe.html).
|
78
124
|
|
79
125
|
Structure classes derived from Ruby's [Struct](http://ruby-doc.org/core-2.2.0/Struct.html):
|
80
126
|
|
81
|
-
*
|
82
|
-
|
83
|
-
*
|
127
|
+
* [ImmutableStruct](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ImmutableStruct.html)
|
128
|
+
Immutable struct where values are set at construction and cannot be changed later.
|
129
|
+
* [MutableStruct](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/MutableStruct.html)
|
130
|
+
Synchronized, mutable struct where values can be safely changed at any time.
|
131
|
+
* [SettableStruct](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/SettableStruct.html)
|
132
|
+
Synchronized, write-once struct where values can be set at most once, either at construction
|
133
|
+
or any time thereafter.
|
84
134
|
|
85
135
|
Thread-safe variables:
|
86
136
|
|
87
|
-
*
|
88
|
-
|
89
|
-
|
90
|
-
*
|
91
|
-
|
92
|
-
|
93
|
-
*
|
94
|
-
|
95
|
-
*
|
137
|
+
* [Agent](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Agent.html): A way to
|
138
|
+
manage shared, mutable, *asynchronous*, independent state. Based on Clojure's
|
139
|
+
[Agent](http://clojure.org/agents).
|
140
|
+
* [Atom](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Atom.html): A way to manage
|
141
|
+
shared, mutable, *synchronous*, independent state. Based on Clojure's
|
142
|
+
[Atom](http://clojure.org/atoms).
|
143
|
+
* [AtomicBoolean](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/AtomicBoolean.html)
|
144
|
+
A boolean value that can be updated atomically.
|
145
|
+
* [AtomicFixnum](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/AtomicFixnum.html)
|
146
|
+
A numeric value that can be updated atomically.
|
147
|
+
* [AtomicReference](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/MutexAtomic.html)
|
148
|
+
An object reference that may be updated atomically.
|
149
|
+
* [Exchanger](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Exchanger.html)
|
150
|
+
A synchronization point at which threads can pair and swap elements within pairs. Based on
|
151
|
+
Java's [Exchanger](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Exchanger.html).
|
152
|
+
* [MVar](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/MVar.html) A synchronized
|
153
|
+
single element container. Based on Haskell's
|
154
|
+
[MVar](https://hackage.haskell.org/package/base-4.8.1.0/docs/Control-Concurrent-MVar.html) and
|
155
|
+
Scala's [MVar](http://docs.typelevel.org/api/scalaz/nightly/index.html#scalaz.concurrent.MVar$).
|
156
|
+
* [ThreadLocalVar](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ThreadLocalVar.html)
|
157
|
+
A variable where the value is different for each thread.
|
158
|
+
* [TVar](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/TVar.html) A transactional
|
159
|
+
variable implementing software transactional memory (STM). Based on Clojure's
|
160
|
+
[Ref](http://clojure.org/refs).
|
96
161
|
|
97
162
|
#### Java-inspired ThreadPools and Other Executors
|
98
163
|
|
99
|
-
*
|
164
|
+
* See the [thread pool](http://ruby-concurrency.github.io/concurrent-ruby/master/file.thread_pools.html)
|
165
|
+
overview, which also contains a list of other Executors available.
|
100
166
|
|
101
167
|
#### Thread Synchronization Classes and Algorithms
|
102
168
|
|
103
|
-
*
|
104
|
-
|
105
|
-
*
|
106
|
-
|
107
|
-
*
|
108
|
-
|
109
|
-
*
|
110
|
-
|
169
|
+
* [CountDownLatch](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/CountDownLatch.html)
|
170
|
+
A synchronization object that allows one thread to wait on multiple other threads.
|
171
|
+
* [CyclicBarrier](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/CyclicBarrier.html)
|
172
|
+
A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point.
|
173
|
+
* [Event](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Event.html) Old school
|
174
|
+
kernel-style event.
|
175
|
+
* [ReadWriteLock](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ReadWriteLock.html)
|
176
|
+
A lock that supports multiple readers but only one writer.
|
177
|
+
* [ReentrantReadWriteLock](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ReentrantReadWriteLock.html)
|
178
|
+
A read/write lock with reentrant and upgrade features.
|
179
|
+
* [Semaphore](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Semaphore.html)
|
180
|
+
A counting-based locking mechanism that uses permits.
|
181
|
+
* [AtomicMarkableReference](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Atomic/AtomicMarkableReference.html)
|
182
|
+
|
183
|
+
#### Deprecated
|
184
|
+
|
185
|
+
Deprecated features are still available and bugs are being fixed, but new features will not be added.
|
186
|
+
|
187
|
+
* ~~[Future](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Future.html):
|
188
|
+
An asynchronous operation that produces a value.~~ Replaced by
|
189
|
+
[Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html).
|
190
|
+
* ~~[.dataflow](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent.html#dataflow-class_method):
|
191
|
+
Built on Futures, Dataflow allows you to create a task that will be scheduled when all of
|
192
|
+
its data dependencies are available.~~ Replaced by
|
193
|
+
[Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html).
|
194
|
+
* ~~[Promise](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promise.html): Similar
|
195
|
+
to Futures, with more features.~~ Replaced by
|
196
|
+
[Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html).
|
197
|
+
* ~~[Delay](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Delay.html) Lazy evaluation
|
198
|
+
of a block yielding an immutable result. Based on Clojure's
|
199
|
+
[delay](https://clojuredocs.org/clojure.core/delay).~~ Replaced by
|
200
|
+
[Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html).
|
201
|
+
* ~~[IVar](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/IVar.html) Similar to a
|
202
|
+
"future" but can be manually assigned once, after which it becomes immutable.~~ Replaced by
|
203
|
+
[Promises](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises.html).
|
204
|
+
|
111
205
|
### Edge Features
|
112
206
|
|
113
207
|
These are available in the `concurrent-ruby-edge` companion gem.
|
114
208
|
|
115
209
|
These features are under active development and may change frequently. They are expected not to
|
116
210
|
keep backward compatibility (there may also lack tests and documentation). Semantic versions will
|
117
|
-
be obeyed though. Features developed in `concurrent-ruby-edge` are expected to move to
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
*
|
131
|
-
*
|
132
|
-
*
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
- **Channel** - Brand new implementation; partial documentation and tests; stability is good.
|
143
|
-
- **LazyRegister** - Missing documentation and tests.
|
144
|
-
- **AtomicMarkableReference, LockFreeLinkedSet, LockFreeStack** - Need real world battle testing.
|
211
|
+
be obeyed though. Features developed in `concurrent-ruby-edge` are expected to move to
|
212
|
+
`concurrent-ruby` when final.
|
213
|
+
|
214
|
+
* [Actor](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Actor.html): Implements
|
215
|
+
the Actor Model, where concurrent actors exchange messages.
|
216
|
+
*Status: Partial documentation and tests; depends on new future/promise framework; stability is good.*
|
217
|
+
* [Channel](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Channel.html):
|
218
|
+
Communicating Sequential Processes ([CSP](https://en.wikipedia.org/wiki/Communicating_sequential_processes)).
|
219
|
+
Functionally equivalent to Go [channels](https://tour.golang.org/concurrency/2) with additional
|
220
|
+
inspiration from Clojure [core.async](https://clojure.github.io/core.async/).
|
221
|
+
*Status: Partial documentation and tests.*
|
222
|
+
* [LazyRegister](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/LazyRegister.html)
|
223
|
+
* [LockFreeLinkedSet](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Edge/LockFreeLinkedSet.html)
|
224
|
+
*Status: will be moved to core soon.*
|
225
|
+
* [LockFreeStack](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/LockFreeStack.html)
|
226
|
+
*Status: missing documentation and tests.*
|
227
|
+
|
228
|
+
## Supported Ruby versions
|
229
|
+
|
230
|
+
MRI 2.0 and above, JRuby 9000, TruffleRuby are supported.
|
231
|
+
This gem should be fully compatible with any interpreter that is compliant with Ruby 2.0 or newer.
|
232
|
+
Java 8 is preferred for JRuby but every Java version on which JRuby 9000 runs is supported.
|
233
|
+
|
234
|
+
The legacy support for Rubinius is kept but it is no longer maintained, if you would like to help
|
235
|
+
please respond to [#739](https://github.com/ruby-concurrency/concurrent-ruby/issues/739).
|
145
236
|
|
146
237
|
## Usage
|
147
238
|
|
@@ -151,13 +242,16 @@ Everything within this gem can be loaded simply by requiring it:
|
|
151
242
|
require 'concurrent'
|
152
243
|
```
|
153
244
|
|
245
|
+
*Requiring only specific abstractions from Concurrent Ruby is not yet supported.*
|
246
|
+
|
154
247
|
To use the tools in the Edge gem it must be required separately:
|
155
248
|
|
156
249
|
```ruby
|
157
250
|
require 'concurrent-edge'
|
158
251
|
```
|
159
252
|
|
160
|
-
If the library does not behave as expected, `Concurrent.use_stdlib_logger(Logger::DEBUG)` could
|
253
|
+
If the library does not behave as expected, `Concurrent.use_stdlib_logger(Logger::DEBUG)` could
|
254
|
+
help to reveal the problem.
|
161
255
|
|
162
256
|
## Installation
|
163
257
|
|
@@ -193,9 +287,9 @@ and run `bundle install` from your shell.
|
|
193
287
|
### C Extensions for MRI
|
194
288
|
|
195
289
|
Potential performance improvements may be achieved under MRI by installing optional C extensions.
|
196
|
-
To
|
197
|
-
gem. `concurrent-ruby` and `concurrent-ruby-ext` are always released together with same
|
198
|
-
Simply install the extension gem too:
|
290
|
+
To minimise installation errors the C extensions are available in the `concurrent-ruby-ext`
|
291
|
+
extension gem. `concurrent-ruby` and `concurrent-ruby-ext` are always released together with same
|
292
|
+
version. Simply install the extension gem too:
|
199
293
|
|
200
294
|
```ruby
|
201
295
|
gem install concurrent-ruby-ext
|
@@ -220,28 +314,32 @@ and load the appropriate C extensions.
|
|
220
314
|
|
221
315
|
#### Note For gem developers
|
222
316
|
|
223
|
-
No gems should depend on `concurrent-ruby-ext`. Doing so will force C extensions on your users.
|
224
|
-
|
317
|
+
No gems should depend on `concurrent-ruby-ext`. Doing so will force C extensions on your users. The
|
318
|
+
best practice is to depend on `concurrent-ruby` and let users to decide if they want C extensions.
|
225
319
|
|
226
320
|
## Maintainers
|
227
321
|
|
228
|
-
*
|
229
|
-
*
|
230
|
-
*
|
231
|
-
|
232
|
-
|
233
|
-
|
322
|
+
* [Petr Chalupa](https://github.com/pitr-ch) (lead maintainer, point-of-contact)
|
323
|
+
* [Jerry D'Antonio](https://github.com/jdantonio) (creator)
|
324
|
+
* [Chris Seaton](https://github.com/chrisseaton)
|
325
|
+
|
326
|
+
### Special Thanks to
|
327
|
+
|
328
|
+
* [Brian Durand](https://github.com/bdurand) for the `ref` gem
|
329
|
+
* [Charles Oliver Nutter](https://github.com/headius) for the `atomic` and `thread_safe` gems
|
330
|
+
* [thedarkone](https://github.com/thedarkone) for the `thread_safe` gem
|
234
331
|
|
235
|
-
|
332
|
+
and to the past maintainers
|
236
333
|
|
237
|
-
*
|
238
|
-
*
|
239
|
-
*
|
334
|
+
* [Michele Della Torre](https://github.com/mighe)
|
335
|
+
* [Paweł Obrok](https://github.com/obrok)
|
336
|
+
* [Lucas Allan](https://github.com/lucasallan)
|
240
337
|
|
241
338
|
## License and Copyright
|
242
339
|
|
243
|
-
*Concurrent Ruby* is free software released under the
|
340
|
+
*Concurrent Ruby* is free software released under the
|
341
|
+
[MIT License](http://www.opensource.org/licenses/MIT).
|
244
342
|
|
245
|
-
The *Concurrent Ruby* [logo](https://github.com/ruby-concurrency/concurrent-ruby/wiki/Logo)
|
246
|
-
|
247
|
-
|
343
|
+
The *Concurrent Ruby* [logo](https://github.com/ruby-concurrency/concurrent-ruby/wiki/Logo) was
|
344
|
+
designed by [David Jones](https://twitter.com/zombyboy). It is Copyright © 2014
|
345
|
+
[Jerry D'Antonio](https://twitter.com/jerrydantonio). All Rights Reserved.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -71,7 +71,7 @@ module Concurrent
|
|
71
71
|
|
72
72
|
all_terminations.chain_resolvable(@terminated)
|
73
73
|
if envelope && envelope.future
|
74
|
-
all_terminations.chain { |fulfilled, _,
|
74
|
+
all_terminations.chain { |fulfilled, _, t_reason| envelope.future.resolve fulfilled, true, t_reason }
|
75
75
|
end
|
76
76
|
|
77
77
|
broadcast(true, [:terminated, reason]) # TODO do not end up in Dead Letter Router
|
@@ -49,7 +49,7 @@ module Concurrent
|
|
49
49
|
# - {RestartingContext} uses
|
50
50
|
# {include:Actor::Behaviour.restarting_behaviour_definition}
|
51
51
|
module Behaviour
|
52
|
-
MESSAGE_PROCESSED = Object.new
|
52
|
+
MESSAGE_PROCESSED = ::Object.new
|
53
53
|
|
54
54
|
require 'concurrent/actor/behaviour/abstract'
|
55
55
|
require 'concurrent/actor/behaviour/awaits'
|
@@ -16,7 +16,7 @@ module Concurrent
|
|
16
16
|
#
|
17
17
|
# Example of ac actor definition:
|
18
18
|
#
|
19
|
-
# {include:file:
|
19
|
+
# {include:file:docs-source/actor/define.out.rb}
|
20
20
|
#
|
21
21
|
# See methods of {AbstractContext} what else can be tweaked, e.g {AbstractContext#default_reference_class}
|
22
22
|
#
|
@@ -90,8 +90,9 @@ module Concurrent
|
|
90
90
|
# can be called from other alternative Reference implementations
|
91
91
|
# @param [Envelope] envelope
|
92
92
|
def on_envelope(envelope)
|
93
|
+
log(DEBUG) { "is #{envelope.future ? 'asked' : 'told'} #{envelope.message.inspect} by #{envelope.sender}" }
|
93
94
|
schedule_execution do
|
94
|
-
log(DEBUG) { "was #{envelope.future ? 'asked' : 'told'} #{envelope.message.inspect} by #{envelope.sender}" }
|
95
|
+
log(DEBUG) { "was #{envelope.future ? 'asked' : 'told'} #{envelope.message.inspect} by #{envelope.sender} - processing" }
|
95
96
|
process_envelope envelope
|
96
97
|
end
|
97
98
|
nil
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -10,9 +10,9 @@ module Concurrent
|
|
10
10
|
# TODO supervision tree, pause children on error in parent, pause may need higher priority
|
11
11
|
# TODO more effective executor
|
12
12
|
|
13
|
-
# {include:file:
|
13
|
+
# {include:file:docs-source/actor/main.md}
|
14
14
|
# @api Actor
|
15
|
-
# @!macro
|
15
|
+
# @!macro warn.edge
|
16
16
|
module Actor
|
17
17
|
|
18
18
|
require 'concurrent/actor/type_check'
|
@@ -35,9 +35,13 @@ module Concurrent
|
|
35
35
|
end
|
36
36
|
|
37
37
|
@root = Concurrent::Promises.delay do
|
38
|
-
Core.
|
39
|
-
|
40
|
-
|
38
|
+
Core.
|
39
|
+
new(parent: nil,
|
40
|
+
name: '/',
|
41
|
+
class: Root,
|
42
|
+
initialized: future = Concurrent::Promises.resolvable_future).
|
43
|
+
reference.
|
44
|
+
tap { future.wait! }
|
41
45
|
end
|
42
46
|
|
43
47
|
# A root actor, a default parent of all actors spawned outside an actor
|