concurrent-ruby 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +138 -0
- data/README.md +73 -105
- data/lib/concurrent/actor.rb +11 -12
- data/lib/concurrent/actor/behaviour/errors_on_unknown_message.rb +1 -1
- data/lib/concurrent/actor/behaviour/linking.rb +4 -1
- data/lib/concurrent/actor/behaviour/pausing.rb +2 -2
- data/lib/concurrent/actor/behaviour/supervised.rb +2 -1
- data/lib/concurrent/actor/behaviour/termination.rb +1 -1
- data/lib/concurrent/actor/context.rb +2 -1
- data/lib/concurrent/actor/core.rb +7 -3
- data/lib/concurrent/actor/utils/balancer.rb +4 -2
- data/lib/concurrent/actor/utils/pool.rb +1 -1
- data/lib/concurrent/agent.rb +1 -22
- data/lib/concurrent/async.rb +1 -79
- data/lib/concurrent/atomic.rb +1 -1
- data/lib/concurrent/atomic/thread_local_var.rb +71 -24
- data/lib/concurrent/atomics.rb +0 -1
- data/lib/concurrent/configuration.rb +11 -5
- data/lib/concurrent/dataflow.rb +1 -30
- data/lib/concurrent/dereferenceable.rb +9 -2
- data/lib/concurrent/executor/indirect_immediate_executor.rb +46 -0
- data/lib/concurrent/executor/java_thread_pool_executor.rb +2 -4
- data/lib/concurrent/executor/ruby_thread_pool_executor.rb +24 -22
- data/lib/concurrent/executor/thread_pool_executor.rb +2 -0
- data/lib/concurrent/executor/timer_set.rb +7 -8
- data/lib/concurrent/executors.rb +1 -0
- data/lib/concurrent/future.rb +7 -29
- data/lib/concurrent/ivar.rb +9 -0
- data/lib/concurrent/logging.rb +3 -0
- data/lib/concurrent/mvar.rb +26 -9
- data/lib/concurrent/observable.rb +33 -0
- data/lib/concurrent/promise.rb +59 -1
- data/lib/concurrent/scheduled_task.rb +1 -0
- data/lib/concurrent/timer_task.rb +18 -18
- data/lib/concurrent/tvar.rb +2 -0
- data/lib/concurrent/version.rb +1 -1
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcb1c203db04de7dece6e92f0398e3daa1bfaffa
|
4
|
+
data.tar.gz: d49524872897159b249ac92cea97c6e859ede6bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ae8a6bad279254f4497ba3bcca32a73ff5c64ea1461de4fdf081f8b91af563fdba5d1d967c16359c2223e23e07cd08f55e7cd6f100d611075b26c8c134a2d8a
|
7
|
+
data.tar.gz: d0b77ea0c9eeb40504cf9353800cee03070632fc3ae9c2ebae7a5a0e5e12313151d496a6203b17a9a376700f9857d14fc69aaace4ccf1f2d270083f1606546c1
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
## Current Release v0.7.1 (4 December 2014)
|
2
|
+
|
3
|
+
Please see the [roadmap](https://github.com/ruby-concurrency/concurrent-ruby/issues/142) for more information on the next planned release.
|
4
|
+
|
5
|
+
* Added `flat_map` method to `Promise`
|
6
|
+
* Added `zip` method to `Promise`
|
7
|
+
* Fixed bug with logging in `Actor`
|
8
|
+
* Improvements to `Promise` tests
|
9
|
+
* Removed actor-experimental warning
|
10
|
+
* Added an `IndirectImmediateExecutor` class
|
11
|
+
* Allow disabling auto termination of global executors
|
12
|
+
* Fix thread leaking in `ThreadLocalVar` (uses `Ref` gem on non-JRuby systems)
|
13
|
+
* Fix thread leaking when pruning pure-Ruby thread pools
|
14
|
+
* Prevent `Actor` from using an `ImmediateExecutor` (causes deadlock)
|
15
|
+
* Added missing synchronizations to `TimerSet`
|
16
|
+
* Fixed bug with return value of `Concurrent::Actor::Utils::Pool#ask`
|
17
|
+
* Fixed timing bug in `TimerTask`
|
18
|
+
* Fixed bug when creating a `JavaThreadPoolExecutor` with minimum pool size of zero
|
19
|
+
* Removed confusing warning when not using native extenstions
|
20
|
+
* Improved documentation
|
21
|
+
|
22
|
+
### Release v0.7.0 (13 August 2014)
|
23
|
+
|
24
|
+
* Merge the [atomic](https://github.com/ruby-concurrency/atomic) gem
|
25
|
+
- Pure Ruby `MutexAtomic` atomic reference class
|
26
|
+
- Platform native atomic reference classes `CAtomic`, `JavaAtomic`, and `RbxAtomic`
|
27
|
+
- Automated [build process](https://github.com/ruby-concurrency/rake-compiler-dev-box)
|
28
|
+
- Fat binary releases for [multiple platforms](https://rubygems.org/gems/concurrent-ruby/versions) including Windows (32/64), Linux (32/64), OS X (64-bit), Solaris (64-bit), and JRuby
|
29
|
+
* C native `CAtomicBoolean`
|
30
|
+
* C native `CAtomicFixnum`
|
31
|
+
* Refactored intermittently failing tests
|
32
|
+
* Added `dataflow!` and `dataflow_with!` methods to match `Future#value!` method
|
33
|
+
* Better handling of timeout in `Agent`
|
34
|
+
* Actor Improvements
|
35
|
+
- Fine-grained implementation using chain of behaviors. Each behavior is responsible for single aspect like: `Termination`, `Pausing`, `Linking`, `Supervising`, etc. Users can create custom Actors easily based on their needs.
|
36
|
+
- Supervision was added. `RestartingContext` will pause on error waiting on its supervisor to decide what to do next ( options are `:terminate!`, `:resume!`, `:reset!`, `:restart!`). Supervising behavior also supports strategies `:one_for_one` and `:one_for_all`.
|
37
|
+
- Linking was added to be able to monitor actor's events like: `:terminated`, `:paused`, `:restarted`, etc.
|
38
|
+
- Dead letter routing added. Rejected envelopes are collected in a configurable actor (default: `Concurrent::Actor.root.ask!(:dead_letter_routing)`)
|
39
|
+
- Old `Actor` class removed and replaced by new implementation previously called `Actress`. `Actress` was kept as an alias for `Actor` to keep compatibility.
|
40
|
+
- `Utils::Broadcast` actor which allows Publish–subscribe pattern.
|
41
|
+
* More executors for managing serialized operations
|
42
|
+
- `SerializedExecution` mixin module
|
43
|
+
- `SerializedExecutionDelegator` for serializing *any* executor
|
44
|
+
* Updated `Async` with serialized execution
|
45
|
+
* Updated `ImmediateExecutor` and `PerThreadExecutor` with full executor service lifecycle
|
46
|
+
* Added a `Delay` to root `Actress` initialization
|
47
|
+
* Minor bug fixes to thread pools
|
48
|
+
* Refactored many intermittently failing specs
|
49
|
+
* Removed Java interop warning `executor.rb:148 warning: ambiguous Java methods found, using submit(java.lang.Runnable)`
|
50
|
+
* Fixed minor bug in `RubyCachedThreadPool` overflow policy
|
51
|
+
* Updated tests to use [RSpec 3.0](http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3)
|
52
|
+
* Removed deprecated `Actor` class
|
53
|
+
* Better support for Rubinius
|
54
|
+
|
55
|
+
### Release v0.6.1 (14 June 2014)
|
56
|
+
|
57
|
+
* Many improvements to `Concurrent::Actress`
|
58
|
+
* Bug fixes to `Concurrent::RubyThreadPoolExecutor`
|
59
|
+
* Fixed several brittle tests
|
60
|
+
* Moved documentation to http://ruby-concurrency.github.io/concurrent-ruby/frames.html
|
61
|
+
|
62
|
+
### Release v0.6.0 (25 May 2014)
|
63
|
+
|
64
|
+
* Added `Concurrent::Observable` to encapsulate our thread safe observer sets
|
65
|
+
* Improvements to new `Channel`
|
66
|
+
* Major improvements to `CachedThreadPool` and `FixedThreadPool`
|
67
|
+
* Added `SingleThreadExecutor`
|
68
|
+
* Added `Current::timer` function
|
69
|
+
* Added `TimerSet` executor
|
70
|
+
* Added `AtomicBoolean`
|
71
|
+
* `ScheduledTask` refactoring
|
72
|
+
* Pure Ruby and JRuby-optimized `PriorityQueue` classes
|
73
|
+
* Updated `Agent` behavior to more closely match Clojure
|
74
|
+
* Observer sets support block callbacks to the `add_observer` method
|
75
|
+
* New algorithm for thread creation in `RubyThreadPoolExecutor`
|
76
|
+
* Minor API updates to `Event`
|
77
|
+
* Rewritten `TimerTask` now an `Executor` instead of a `Runnable`
|
78
|
+
* Fixed many brittle specs
|
79
|
+
* Renamed `FixedThreadPool` and `CachedThreadPool` to `RubyFixedThreadPool` and `RubyCachedThreadPool`
|
80
|
+
* Created JRuby optimized `JavaFixedThreadPool` and `JavaCachedThreadPool`
|
81
|
+
* Consolidated fixed thread pool tests into `spec/concurrent/fixed_thread_pool_shared.rb` and `spec/concurrent/cached_thread_pool_shared.rb`
|
82
|
+
* `FixedThreadPool` now subclasses `RubyFixedThreadPool` or `JavaFixedThreadPool` as appropriate
|
83
|
+
* `CachedThreadPool` now subclasses `RubyCachedThreadPool` or `JavaCachedThreadPool` as appropriate
|
84
|
+
* New `Delay` class
|
85
|
+
* `Concurrent::processor_count` helper function
|
86
|
+
* New `Async` module
|
87
|
+
* Renamed `NullThreadPool` to `PerThreadExecutor`
|
88
|
+
* Deprecated `Channel` (we are planning a new implementation based on [Go](http://golangtutorials.blogspot.com/2011/06/channels-in-go.html))
|
89
|
+
* Added gem-level [configuration](http://robots.thoughtbot.com/mygem-configure-block)
|
90
|
+
* Deprecated `$GLOBAL_THREAD_POOL` in lieu of gem-level configuration
|
91
|
+
* Removed support for Ruby [1.9.2](https://www.ruby-lang.org/en/news/2013/12/17/maintenance-of-1-8-7-and-1-9-2/)
|
92
|
+
* New `RubyThreadPoolExecutor` and `JavaThreadPoolExecutor` classes
|
93
|
+
* All thread pools now extend the appropriate thread pool executor classes
|
94
|
+
* All thread pools now support `:overflow_policy` (based on Java's [reject policies](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html))
|
95
|
+
* Deprecated `UsesGlobalThreadPool` in lieu of explicit `:executor` option (dependency injection) on `Future`, `Promise`, and `Agent`
|
96
|
+
* Added `Concurrent::dataflow_with(executor, *inputs)` method to support executor dependency injection for dataflow
|
97
|
+
* Software transactional memory with `TVar` and `Concurrent::atomically`
|
98
|
+
* First implementation of [new, high-performance](https://github.com/ruby-concurrency/concurrent-ruby/pull/49) `Channel`
|
99
|
+
* `Actor` is deprecated in favor of new experimental actor implementation [#73](https://github.com/ruby-concurrency/concurrent-ruby/pull/73). To avoid namespace collision it is living in `Actress` namespace until `Actor` is removed in next release.
|
100
|
+
|
101
|
+
### Release v0.5.0
|
102
|
+
|
103
|
+
This is the most significant release of this gem since its inception. This release includes many improvements and optimizations. It also includes several bug fixes. The major areas of focus for this release were:
|
104
|
+
|
105
|
+
* Stability improvements on Ruby versions with thread-level parallelism ([JRuby](http://jruby.org/) and [Rubinius](http://rubini.us/))
|
106
|
+
* Creation of new low-level concurrency abstractions
|
107
|
+
* Internal refactoring to use the new low-level abstractions
|
108
|
+
|
109
|
+
Most of these updates had no effect on the gem API. There are a few notable exceptions which were unavoidable. Please read the [release notes](API-Updates-in-v0.5.0) for more information.
|
110
|
+
|
111
|
+
Specific changes include:
|
112
|
+
|
113
|
+
* New class `IVar`
|
114
|
+
* New class `MVar`
|
115
|
+
* New class `ThreadLocalVar`
|
116
|
+
* New class `AtomicFixnum`
|
117
|
+
* New class method `dataflow`
|
118
|
+
* New class `Condition`
|
119
|
+
* New class `CountDownLatch`
|
120
|
+
* New class `DependencyCounter`
|
121
|
+
* New class `SafeTaskExecutor`
|
122
|
+
* New class `CopyOnNotifyObserverSet`
|
123
|
+
* New class `CopyOnWriteObserverSet`
|
124
|
+
* `Future` updated with `execute` API
|
125
|
+
* `ScheduledTask` updated with `execute` API
|
126
|
+
* New `Promise` API
|
127
|
+
* `Future` now extends `IVar`
|
128
|
+
* `Postable#post?` now returns an `IVar`
|
129
|
+
* Thread safety fixes to `Dereferenceable`
|
130
|
+
* Thread safety fixes to `Obligation`
|
131
|
+
* Thread safety fixes to `Supervisor`
|
132
|
+
* Thread safety fixes to `Event`
|
133
|
+
* Various other thread safety (race condition) fixes
|
134
|
+
* Refactored brittle tests
|
135
|
+
* Implemented pending tests
|
136
|
+
* Added JRuby and Rubinius as Travis CI build targets
|
137
|
+
* Added [CodeClimate](https://codeclimate.com/) code review
|
138
|
+
* Improved YARD documentation
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Concurrent Ruby
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/concurrent-ruby.
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/concurrent-ruby.svg)](http://badge.fury.io/rb/concurrent-ruby) [![Build Status](https://travis-ci.org/ruby-concurrency/concurrent-ruby.svg?branch=master)](https://travis-ci.org/ruby-concurrency/concurrent-ruby) [![Coverage Status](https://img.shields.io/coveralls/ruby-concurrency/concurrent-ruby/master.svg)](https://coveralls.io/r/ruby-concurrency/concurrent-ruby) [![Code Climate](https://codeclimate.com/github/ruby-concurrency/concurrent-ruby.svg)](https://codeclimate.com/github/ruby-concurrency/concurrent-ruby) [![Inline docs](http://inch-ci.org/github/ruby-concurrency/concurrent-ruby.svg)](http://inch-ci.org/github/ruby-concurrency/concurrent-ruby) [![Dependency Status](https://gemnasium.com/ruby-concurrency/concurrent-ruby.svg)](https://gemnasium.com/ruby-concurrency/concurrent-ruby) [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT) [![Gitter chat](http://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/ruby-concurrency/concurrent-ruby)
|
3
3
|
|
4
4
|
<table>
|
5
5
|
<tr>
|
@@ -30,126 +30,94 @@
|
|
30
30
|
</p>
|
31
31
|
</td>
|
32
32
|
<td align="right" valign="top">
|
33
|
-
<img src="https://raw.githubusercontent.com/
|
33
|
+
<img src="https://raw.githubusercontent.com/ruby-concurrency/concurrent-ruby/master/doc/logo/concurrent-ruby-logo-300x300.png"/>
|
34
34
|
</td>
|
35
35
|
</tr>
|
36
36
|
</table>
|
37
37
|
|
38
|
+
### Supported Ruby versions
|
39
|
+
|
40
|
+
MRI 1.9.3, 2.0, 2.1, JRuby (1.9 mode), and Rubinius 2.x are supported.
|
41
|
+
Although native code is used for performance optimizations on some platforms, all functionality
|
42
|
+
is available in pure Ruby. This gem should be fully compatible with any interpreter that is
|
43
|
+
compliant with Ruby 1.9.3 or newer.
|
44
|
+
|
38
45
|
## Features & Documentation
|
39
46
|
|
40
|
-
|
41
|
-
or the [API documentation](http://ruby-concurrency.github.io/concurrent-ruby/frames.html)
|
42
|
-
for more information or join our [mailing list](http://groups.google.com/group/concurrent-ruby).
|
43
|
-
|
44
|
-
There are many concurrency abstractions in this library. These abstractions can be broadly categorized
|
45
|
-
into several general groups:
|
46
|
-
|
47
|
-
* Asynchronous concurrency abstractions including
|
48
|
-
[Agent](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Agent.html),
|
49
|
-
[Async](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Async.html),
|
50
|
-
[Future](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Future.html),
|
51
|
-
[Promise](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Promise.html),
|
52
|
-
[ScheduledTask](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ScheduledTask.html),
|
53
|
-
and [TimerTask](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/TimerTask.html)
|
54
|
-
* Fast, light-weight [Actor model](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Actor.html) implementation.
|
55
|
-
* Thread-safe variables including
|
56
|
-
[I-Structures](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/IVar.html),
|
57
|
-
[M-Structures](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/MVar.html),
|
58
|
-
[thread-local variables](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ThreadLocalVar.html),
|
59
|
-
and [software transactional memory](https://github.com/ruby-concurrency/concurrent-ruby/wiki/TVar-(STM))
|
60
|
-
* Thread synchronization classes and algorithms including
|
61
|
-
[condition](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Condition.html),
|
62
|
-
[countdown latch](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/CountDownLatch.html),
|
63
|
-
[dataflow](https://github.com/ruby-concurrency/concurrent-ruby/wiki/Dataflow),
|
64
|
-
[event](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Event.html),
|
65
|
-
[exchanger](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Exchanger.html),
|
66
|
-
and [timeout](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent.html#timeout-class_method)
|
67
|
-
* Java-inspired [executors](https://github.com/ruby-concurrency/concurrent-ruby/wiki/Thread%20Pools) (thread pools and more)
|
68
|
-
* [And many more](http://ruby-concurrency.github.io/concurrent-ruby/index.html)...
|
69
|
-
|
70
|
-
### Semantic Versioning
|
71
|
-
|
72
|
-
This gem adheres to the rules of [semantic versioning](http://semver.org/).
|
47
|
+
We have a roadmap guiding our work toward the [v1.0.0 release](https://github.com/ruby-concurrency/concurrent-ruby/wiki/v1.0-Roadmap).
|
73
48
|
|
74
|
-
|
49
|
+
The primary site for documentation is the automatically generated [API documentation](http://ruby-concurrency.github.io/concurrent-ruby/frames.html)
|
75
50
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
###
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
51
|
+
We also have a [mailing list](http://groups.google.com/group/concurrent-ruby).
|
52
|
+
|
53
|
+
This library contains a variety of concurrency abstractions at high and low levels. One of the high-level abstractions is likely to meet most common needs.
|
54
|
+
|
55
|
+
### High-level, general-purpose asynchronous concurrency abstractions
|
56
|
+
|
57
|
+
* [Actor](./doc/actor/main.md): Implements the Actor Model, where concurrent actors exchange messages.
|
58
|
+
* [Agent](./doc/agent.md): A single atomic value that represents an identity.
|
59
|
+
* [Async](./doc/async.md): A mixin module that provides simple asynchronous behavior to any standard class/object or object.
|
60
|
+
* [Future](./doc/future.md): An asynchronous operation that produces a value.
|
61
|
+
* [Dataflow](./doc/dataflow.md): Built on Futures, Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available.
|
62
|
+
* [Promise](./doc/promise.md): Similar to Futures, with more features.
|
63
|
+
* [ScheduledTask](./doc/scheduled_task.md): Like a Future scheduled for a specific future time.
|
64
|
+
* [TimerTask](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/TimerTask.html): A Thread that periodically wakes up to perform work at regular intervals.
|
65
|
+
|
66
|
+
|
67
|
+
### Java-inspired ThreadPools and other executors
|
68
|
+
|
69
|
+
* See [ThreadPool](./doc/thread_pools.md) overview, which also contains a list of other Executors available.
|
70
|
+
|
71
|
+
### Thread-safe Observers
|
72
|
+
|
73
|
+
* [Concurrent::Observable](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Observable.html) mixin module
|
74
|
+
* [CopyOnNotifyObserverSet](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/CopyOnNotifyObserverSet.html)
|
75
|
+
* [CopyOnWriteObserverSet](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/CopyOnWriteObserverSet.html)
|
76
|
+
|
77
|
+
### Thread synchronization classes and algorithms
|
78
|
+
Lower-level abstractions mainly used as building blocks.
|
79
|
+
|
80
|
+
* [condition](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Condition.html)
|
81
|
+
* [countdown latch](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/CountDownLatch.html)
|
82
|
+
* [cyclic barrier](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/CyclicBarrier.html)
|
83
|
+
* [event](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Event.html)
|
84
|
+
* [exchanger](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Exchanger.html)
|
85
|
+
* [timeout](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent.html#timeout-class_method)
|
86
|
+
* [timer](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent.html#timer-class_method)
|
87
|
+
|
88
|
+
### Thread-safe variables
|
89
|
+
Lower-level abstractions mainly used as building blocks.
|
90
|
+
|
91
|
+
* [AtomicBoolean](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/AtomicBoolean.html)
|
92
|
+
* [AtomicFixnum](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/AtomicFixnum.html)
|
93
|
+
* AtomicReference (no docs currently available, check source)
|
94
|
+
* [I-Structures](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/IVar.html) (IVar)
|
95
|
+
* [M-Structures](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/MVar.html) (MVar)
|
96
|
+
* [thread-local variables](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ThreadLocalVar.html)
|
97
|
+
* [software transactional memory](./doc/tvar.md) (TVar)
|
112
98
|
|
113
|
-
Actor:
|
114
99
|
|
115
|
-
```ruby
|
116
|
-
class Counter < Concurrent::Actor::Context
|
117
|
-
# Include context of an actor which gives this class access to reference
|
118
|
-
# and other information about the actor
|
119
|
-
|
120
|
-
# use initialize as you wish
|
121
|
-
def initialize(initial_value)
|
122
|
-
@count = initial_value
|
123
|
-
end
|
124
|
-
|
125
|
-
# override on_message to define actor's behaviour
|
126
|
-
def on_message(message)
|
127
|
-
if Integer === message
|
128
|
-
@count += message
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end #
|
132
|
-
|
133
|
-
# Create new actor naming the instance 'first'.
|
134
|
-
# Return value is a reference to the actor, the actual actor is never returned.
|
135
|
-
counter = Counter.spawn(:first, 5)
|
136
|
-
|
137
|
-
# Tell a message and forget returning self.
|
138
|
-
counter.tell(1)
|
139
|
-
counter << 1
|
140
|
-
# (First counter now contains 7.)
|
141
|
-
|
142
|
-
# Send a messages asking for a result.
|
143
|
-
counter.ask(0).class
|
144
|
-
counter.ask(0).value
|
145
|
-
```
|
146
100
|
|
147
101
|
## Installing and Building
|
148
102
|
|
149
103
|
This gem includes several platform-specific optimizations. To reduce the possibility of
|
150
104
|
compilation errors, we provide pre-compiled gem packages for several platforms as well
|
151
105
|
as a pure-Ruby build. Installing the gem should be no different than installing any other
|
152
|
-
Rubygems-hosted gem.
|
106
|
+
Rubygems-hosted gem. Rubygems will automatically detect your platform and install the
|
107
|
+
appropriate pre-compiled build. You should never see Rubygems attempt to compile the gem
|
108
|
+
on installation. Additionally, to ensure compatability with the largest possible number
|
109
|
+
of Ruby interpreters, the C extensions will *never* load under any Ruby other than MRI,
|
110
|
+
even when installed.
|
111
|
+
|
112
|
+
The following gem builds will be built at every release:
|
113
|
+
|
114
|
+
* concurrent-ruby-x.y.z.gem (pure Ruby)
|
115
|
+
* concurrent-ruby-x.y.z-java.gem (JRuby)
|
116
|
+
* concurrent-ruby-x.y.z-x86-linux.gem (Linux 32-bit)
|
117
|
+
* concurrent-ruby-x.y.z-x86_64-linux.gem (Linux 64-bit)
|
118
|
+
* concurrent-ruby-x.y.z-x86-mingw32.gem (Windows 32-bit)
|
119
|
+
* concurrent-ruby-x.y.z-x64-mingw32.gem (Windows 64-bit)
|
120
|
+
* concurrent-ruby-x.y.z-x86-solaris-2.11.gem (Solaris)
|
153
121
|
|
154
122
|
### Installing
|
155
123
|
|
data/lib/concurrent/actor.rb
CHANGED
@@ -5,11 +5,17 @@ require 'concurrent/logging'
|
|
5
5
|
require 'concurrent/atomic/synchronization'
|
6
6
|
|
7
7
|
module Concurrent
|
8
|
-
# TODO https://github.com/celluloid/celluloid/wiki/Supervision-Groups
|
8
|
+
# TODO https://github.com/celluloid/celluloid/wiki/Supervision-Groups ?
|
9
|
+
# TODO Remote actors using DRb
|
10
|
+
# TODO IO interoperation
|
11
|
+
# TODO un/become
|
9
12
|
|
10
13
|
# TODO doc
|
11
14
|
# - what happens if I try to supervise using a normal Context?
|
12
|
-
|
15
|
+
# - how to change behaviours
|
16
|
+
# - how to implement custom restarting?
|
17
|
+
# - pool for io operations using different executor
|
18
|
+
# - document guaranteed ordering
|
13
19
|
|
14
20
|
# {include:file:doc/actor/main.md}
|
15
21
|
module Actor
|
@@ -61,13 +67,10 @@ module Concurrent
|
|
61
67
|
# @param args see {.spawn_optionify}
|
62
68
|
# @return [Reference] never the actual actor
|
63
69
|
def self.spawn(*args, &block)
|
64
|
-
experimental_acknowledged? or
|
65
|
-
warn '[EXPERIMENTAL] A full release of `Actor`, is expected in the 0.7.0 release.'
|
66
|
-
|
67
70
|
if Actor.current
|
68
71
|
Core.new(spawn_optionify(*args).merge(parent: Actor.current), &block).reference
|
69
72
|
else
|
70
|
-
root.ask([:spawn, spawn_optionify(*args), block]).value
|
73
|
+
root.ask([:spawn, spawn_optionify(*args), block]).value!
|
71
74
|
end
|
72
75
|
end
|
73
76
|
|
@@ -77,7 +80,7 @@ module Concurrent
|
|
77
80
|
end
|
78
81
|
|
79
82
|
# @overload spawn_optionify(context_class, name, *args)
|
80
|
-
# @param [
|
83
|
+
# @param [AbstractContext] context_class to be spawned
|
81
84
|
# @param [String, Symbol] name of the instance, it's used to generate the {Core#path} of the actor
|
82
85
|
# @param args for context_class instantiation
|
83
86
|
# @overload spawn_optionify(opts)
|
@@ -94,11 +97,7 @@ module Concurrent
|
|
94
97
|
|
95
98
|
# call this to disable experimental warning
|
96
99
|
def self.i_know_it_is_experimental!
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
def self.experimental_acknowledged?
|
101
|
-
!!@experimental_acknowledged
|
100
|
+
warn 'Method Actor.i_know_it_is_experimental! is deprecated. The Actors are no longer experimental.'
|
102
101
|
end
|
103
102
|
end
|
104
103
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Concurrent
|
2
2
|
module Actor
|
3
3
|
module Behaviour
|
4
|
-
# Simply fails when message arrives here.
|
4
|
+
# Simply fails when message arrives here. It's usually the last behaviour.
|
5
5
|
class ErrorsOnUnknownMessage < Abstract
|
6
6
|
def on_envelope(envelope)
|
7
7
|
raise UnknownMessage, envelope
|
@@ -2,8 +2,9 @@ module Concurrent
|
|
2
2
|
module Actor
|
3
3
|
module Behaviour
|
4
4
|
|
5
|
-
# Links the actor to other actors and sends events to them,
|
5
|
+
# Links the actor to other actors and sends actor's events to them,
|
6
6
|
# like: `:terminated`, `:paused`, errors, etc
|
7
|
+
# TODO example
|
7
8
|
class Linking < Abstract
|
8
9
|
def initialize(core, subsequent)
|
9
10
|
super core, subsequent
|
@@ -16,6 +17,8 @@ module Concurrent
|
|
16
17
|
link envelope.sender
|
17
18
|
when :unlink
|
18
19
|
unlink envelope.sender
|
20
|
+
when :linked?
|
21
|
+
@linked.include? envelope.sender
|
19
22
|
else
|
20
23
|
pass envelope
|
21
24
|
end
|
@@ -5,8 +5,8 @@ module Concurrent
|
|
5
5
|
# Allows to pause actors on errors.
|
6
6
|
# When paused all arriving messages are collected and processed after the actor
|
7
7
|
# is resumed or reset. Resume will simply continue with next message.
|
8
|
-
# Reset also reinitialized context.
|
9
|
-
#
|
8
|
+
# Reset also reinitialized context.
|
9
|
+
# TODO example
|
10
10
|
class Pausing < Abstract
|
11
11
|
def initialize(core, subsequent)
|
12
12
|
super core, subsequent
|