1
1
# Concurrent Ruby
2
- [](http://badge.fury.io/rb/concurrent-ruby) [](https://travis-ci.org/ruby-concurrency/concurrent-ruby) [](https://coveralls.io/r/ruby-concurrency/concurrent-ruby) [](https://codeclimate.com/github/ruby-concurrency/concurrent-ruby) [](http://inch-ci.org/github/ruby-concurrency/concurrent-ruby) [](https://gemnasium.com/ruby-concurrency/concurrent-ruby) [](http://opensource.org/licenses/MIT) [](https://gitter.im/ruby-concurrency/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 ) [ ![ 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 >
@@ -50,7 +50,7 @@ We also have a [mailing list](http://groups.google.com/group/concurrent-ruby).
50
50
51
51
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.
52
52
53
- ### High-level, general- purpose asynchronous concurrency abstractions
53
+ #### General- purpose Concurrency Abstractions
54
54
55
55
* [ Async] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Async.html ) : A mixin module that provides simple asynchronous behavior to any standard class/object or object.
56
56
* [ Atom] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Atom.html ) : A way to manage shared, synchronous, independent state.
@@ -60,47 +60,58 @@ This library contains a variety of concurrency abstractions at high and low leve
60
60
* [ ScheduledTask] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ScheduledTask.html ) : Like a Future scheduled for a specific future time.
61
61
* [ TimerTask] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/TimerTask.html ) : A Thread that periodically wakes up to perform work at regular intervals.
62
62
63
- ### Java-inspired ThreadPools and other executors
63
+ #### Thread-safe Value Objects
64
64
65
- * See [ ThreadPool] ( http://ruby-concurrency.github.io/concurrent-ruby/file.thread_pools.html ) overview, which also contains a list of other Executors available.
65
+ * ` Maybe ` A thread-safe, immutable object representing an optional value, based on
66
+ [ Haskell Data.Maybe] ( https://hackage.haskell.org/package/base-4.2.0.1/docs/Data-Maybe.html ) .
67
+ * ` Delay ` Lazy evaluation of a block yielding an immutable result. Based on Clojure's
68
+ [ delay] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Delay.html ) .
69
+
70
+ #### Thread-safe Structures
66
71
67
- * Thread-safe structure classes derived from Ruby's [ Struct] ( http://ruby-doc.org/core-2.2.0/Struct.html )
72
+ Derived from Ruby's [ Struct] ( http://ruby-doc.org/core-2.2.0/Struct.html ) :
68
73
69
74
* ` ImmutableStruct ` Immutable struct where values are set at construction and cannot be changed later.
70
75
* ` MutableStruct ` Synchronized, mutable struct where values can be safely changed at any time.
71
76
* ` SettableStruct ` Synchronized, write-once struct where values can be set at most once, either at construction or any time thereafter.
72
77
73
- ### Thread synchronization classes and algorithms
78
+ #### Java-inspired ThreadPools and Other Executors
79
+
80
+ * See [ ThreadPool] ( http://ruby-concurrency.github.io/concurrent-ruby/file.thread_pools.html ) overview, which also contains a list of other Executors available.
81
+
82
+ #### Thread Synchronization Classes and Algorithms
74
83
75
84
* [ CountdownLatch] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/CountDownLatch.html )
76
85
* [ CyclicBarrier] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/CyclicBarrier.html )
77
86
* [ Event] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Event.html )
78
87
* [ Semaphore] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Semaphore.html )
79
- * [ Timeout] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent.html#timeout-class_method )
80
- * [ Timer] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent.html#timer-class_method )
81
88
82
- ### Thread-safe variables
89
+ #### Thread-safe Variables
83
90
84
91
* [ AtomicBoolean] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/AtomicBoolean.html )
85
92
* [ AtomicFixnum] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/AtomicFixnum.html )
86
93
* [ AtomicReference] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/MutexAtomic.html )
87
- * [ Delay] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Delay.html )
88
94
* [ I-Structures] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/IVar.html ) (IVar)
89
95
* [ M-Structures] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/MVar.html ) (MVar)
90
96
* [ Thread-local variables] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ThreadLocalVar.html )
91
97
* [ Software transactional memory] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/TVar.html ) (TVar)
92
98
* [ ReadWriteLock] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ReadWriteLock.html )
93
99
94
- ### Edge features
100
+ ### Edge Features
95
101
96
- They are available in the ` concurrent-ruby-edge ` companion gem, install with ` gem install concurrent-ruby-edge ` .
102
+ These are available in the ` concurrent-ruby-edge ` companion gem, installed with ` gem install concurrent-ruby-edge ` .
97
103
98
104
These features are under active development and may change frequently. They are expected not to
99
105
keep backward compatibility (there may also lack tests and documentation). Semantic versions will
100
106
be obeyed though. Features developed in ` concurrent-ruby-edge ` are expected to move to ` concurrent-ruby ` when final.
101
107
102
108
* [ Actor] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Actor.html ) :
103
109
Implements the Actor Model, where concurrent actors exchange messages.
110
+ * [ new Future Framework] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Edge.html ) - new
111
+ unified implementation of Futures and Promises which combines Features of previous ` Future ` ,
112
+ ` Promise ` , ` IVar ` , ` Event ` , ` Probe ` , ` dataflow ` , ` Delay ` , ` TimerTask ` into single framework. It uses extensively
113
+ new synchronization layer to make all the paths ** lock-free** with exception of blocking threads on ` #wait ` .
114
+ It offers better performance and does not block threads when not required.
104
115
* [ Agent] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Agent.html ) : A single atomic value that represents an identity.
105
116
* [ Channel] ( http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Channel.html ) :
106
117
Communicating Sequential Processes (CSP).
@@ -114,6 +125,17 @@ be obeyed though. Features developed in `concurrent-ruby-edge` are expected to m
114
125
intended).
115
126
116
127
128
+ #### Statuses:
129
+
130
+ * Why is not in core?*
131
+
132
+ - ** Actor** - partial documentation and tests, stability good.
133
+ - ** Future/Promise Framework** - partial documentation and tests, stability good.
134
+ - ** Agent** - incomplete behaviour compared to Clojure's model, stability good.
135
+ - ** Channel** - missing documentation, stability good.
136
+ - ** Exchanger** - known race issue.
137
+ - ** LazyRegister** - missing documentation and tests.
138
+
117
139
## Usage
118
140
119
141
All abstractions within this gem can be loaded simply by requiring it:
@@ -131,32 +153,36 @@ require 'concurrent' # everything
131
153
132
154
require ' concurrent/atomics' # atomic and thread synchronization classes
133
155
require ' concurrent/executors' # Thread pools and other executors
134
- require ' concurrent/utilities' # utility methods such as processor count and timers
135
156
136
157
# individual abstractions
137
158
138
- require ' concurrent/agent' # Concurrent::Agent
139
- require ' concurrent/async' # Concurrent::Async
140
- require ' concurrent/atomic' # Concurrent::Atomic (formerly the `atomic` gem)
141
- require ' concurrent/dataflow' # Concurrent::dataflow
142
- require ' concurrent/delay' # Concurrent::Delay
143
- require ' concurrent/exchanger' # Concurrent::Exchanger
144
- require ' concurrent/future' # Concurrent::Future
145
- require ' concurrent/ivar' # Concurrent::IVar
146
- require ' concurrent/lazy_register' # Concurrent::LazyRegister
147
- require ' concurrent/mvar' # Concurrent::MVar
148
- require ' concurrent/promise' # Concurrent::Promise
149
- require ' concurrent/scheduled_task' # Concurrent::ScheduledTask
150
- require ' concurrent/timer_task' # Concurrent::TimerTask
151
- require ' concurrent/tvar' # Concurrent::TVar
159
+ require ' concurrent/async' # Concurrent::Async
160
+ require ' concurrent/atom' # Concurrent::Atom
161
+ require ' concurrent/dataflow' # Concurrent::dataflow
162
+ require ' concurrent/delay' # Concurrent::Delay
163
+ require ' concurrent/future' # Concurrent::Future
164
+ require ' concurrent/immutable_struct' # Concurrent::ImmutableStruct
165
+ require ' concurrent/ivar' # Concurrent::IVar
166
+ require ' concurrent/maybe' # Concurrent::Maybe
167
+ require ' concurrent/mutable_struct' # Concurrent::MutableStruct
168
+ require ' concurrent/mvar' # Concurrent::MVar
169
+ require ' concurrent/promise' # Concurrent::Promise
170
+ require ' concurrent/scheduled_task' # Concurrent::ScheduledTask
171
+ require ' concurrent/settable_struct' # Concurrent::SettableStruct
172
+ require ' concurrent/timer_task' # Concurrent::TimerTask
173
+ require ' concurrent/tvar' # Concurrent::TVar
152
174
153
175
# experimental - available in `concurrent-ruby-edge` companion gem
154
176
155
177
require ' concurrent/actor' # Concurrent::Actor and supporting code
178
+ require ' concurrent/edge/future' # new Future Framework
179
+ require ' concurrent/agent' # Concurrent::Agent
156
180
require ' concurrent/channel ' # Concurrent::Channel and supporting code
181
+ require ' concurrent/exchanger' # Concurrent::Exchanger
182
+ require ' concurrent/lazy_register' # Concurrent::LazyRegister
157
183
```
158
184
159
- If the library does not behave as expected, ` Concurrent.use_stdlib_logger(Logger::DEBUG) ` could help to revel the problem.
185
+ If the library does not behave as expected, ` Concurrent.use_stdlib_logger(Logger::DEBUG) ` could help to reveal the problem.
160
186
161
187
## Installation
162
188
@@ -241,7 +267,7 @@ bundle exec rake compile # Compile all the extensions
241
267
* [ Petr Chalupa] ( https://github.com/pitr-ch )
242
268
* [ Paweł Obrok] ( https://github.com/obrok )
243
269
244
- ### Contributing
270
+ ## Contributing
245
271
246
272
1 . Fork it
247
273
2 . Create your feature branch (` git checkout -b my-new-feature ` )
0 commit comments