Skip to content

Commit 3cc024e

Browse files
committed
Extracted actor & channel into an "edge" gem.
1 parent dbcd08c commit 3cc024e

16 files changed

+110
-29
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,13 @@ This library contains a variety of concurrency abstractions at high and low leve
5252

5353
### High-level, general-purpose asynchronous concurrency abstractions
5454

55-
* [Actor](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Actor.html): Implements the Actor Model, where concurrent actors exchange messages.
5655
* [Agent](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Agent.html): A single atomic value that represents an identity.
5756
* [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.
5857
* [Future](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Future.html): An asynchronous operation that produces a value.
5958
* [Dataflow](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent.html#dataflow-class_method): Built on Futures, Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available.
6059
* [Promise](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Promise.html): Similar to Futures, with more features.
6160
* [ScheduledTask](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ScheduledTask.html): Like a Future scheduled for a specific future time.
6261
* [TimerTask](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/TimerTask.html): A Thread that periodically wakes up to perform work at regular intervals.
63-
* [Channel](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Channel.html): Communicating Sequential Processes (CSP).
6462

6563
### Java-inspired ThreadPools and other executors
6664

@@ -90,6 +88,14 @@ This library contains a variety of concurrency abstractions at high and low leve
9088
* [Software transactional memory](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/TVar.html) (TVar)
9189
* [ReadWriteLock](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ReadWriteLock.html)
9290

91+
### Experimental features
92+
93+
These features are under active, experimental development and may change frequently. They are minimally
94+
documented and tested. They are available in the `concurrent-ruby-experimental` companion gem.
95+
96+
* [Actor](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Actor.html): Implements the Actor Model, where concurrent actors exchange messages.
97+
* [Channel](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Channel.html): Communicating Sequential Processes (CSP).
98+
9399
## Usage
94100

95101
All abstractions within this gem can be loaded simply by requiring it:
@@ -105,9 +111,7 @@ require 'concurrent' # everything
105111

106112
# groups
107113

108-
require 'concurrent/actor' # Concurrent::Actor and supporting code
109114
require 'concurrent/atomics' # atomic and thread synchronization classes
110-
require 'concurrent/channels' # Concurrent::Channel and supporting code
111115
require 'concurrent/executors' # Thread pools and other executors
112116
require 'concurrent/utilities' # utility methods such as processor count and timers
113117

@@ -127,6 +131,11 @@ require 'concurrent/promise' # Concurrent::Promise
127131
require 'concurrent/scheduled_task' # Concurrent::ScheduledTask
128132
require 'concurrent/timer_task' # Concurrent::TimerTask
129133
require 'concurrent/tvar' # Concurrent::TVar
134+
135+
# experimental - available in `concurrent-ruby-experimental` companion gem
136+
137+
require 'concurrent/actor' # Concurrent::Actor and supporting code
138+
require 'concurrent/channel ' # Concurrent::Channel and supporting code
130139
```
131140

132141
## Installation

Rakefile

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
#!/usr/bin/env rake
22

3+
require_relative './lib/concurrent/version'
4+
require_relative './lib/concurrent/edge/version'
35
require_relative './lib/extension_helper'
46

57
## load the two gemspec files
68
CORE_GEMSPEC = Gem::Specification.load('concurrent-ruby.gemspec')
79
EXT_GEMSPEC = Gem::Specification.load('concurrent-ruby-ext.gemspec')
10+
EDGE_GEMSPEC = Gem::Specification.load('concurrent-ruby-edge.gemspec')
811

912
## constants used for compile/build tasks
1013

1114
GEM_NAME = 'concurrent-ruby'
12-
EXTENSION_NAME = 'extension'
15+
EXT_NAME = 'extension'
16+
EDGE_NAME = 'edge'
1317
JAVA_EXT_NAME = 'concurrent_ruby_ext'
1418

1519
if Concurrent.jruby?
1620
CORE_GEM = "#{GEM_NAME}-#{Concurrent::VERSION}-java.gem"
1721
else
1822
CORE_GEM = "#{GEM_NAME}-#{Concurrent::VERSION}.gem"
19-
EXTENSION_GEM = "#{GEM_NAME}-ext-#{Concurrent::VERSION}.gem"
23+
EXT_GEM = "#{GEM_NAME}-ext-#{Concurrent::VERSION}.gem"
2024
NATIVE_GEM = "#{GEM_NAME}-ext-#{Concurrent::VERSION}-#{Gem::Platform.new(RUBY_PLATFORM)}.gem"
25+
EDGE_GEM = "#{GEM_NAME}-edge-#{Concurrent::Edge::VERSION}.gem"
2126
end
2227

2328
## safely load all the rake tasks in the `tasks` directory
@@ -49,7 +54,7 @@ elsif Concurrent.allow_c_extensions?
4954
## create the compile tasks for the extension gem
5055
require 'rake/extensiontask'
5156

52-
Rake::ExtensionTask.new(EXTENSION_NAME, EXT_GEMSPEC) do |ext|
57+
Rake::ExtensionTask.new(EXT_NAME, EXT_GEMSPEC) do |ext|
5358
ext.ext_dir = 'ext/concurrent'
5459
ext.lib_dir = 'lib/concurrent'
5560
ext.source_pattern = '*.{c,h}'
@@ -63,9 +68,9 @@ elsif Concurrent.allow_c_extensions?
6368
'x64-mingw32' => 'x86_64-w64-mingw32'
6469
}
6570
platforms.each do |platform, prefix|
66-
task "copy:#{EXTENSION_NAME}:#{platform}:#{ruby_version}" do |t|
71+
task "copy:#{EXT_NAME}:#{platform}:#{ruby_version}" do |t|
6772
%w[lib tmp/#{platform}/stage/lib].each do |dir|
68-
so_file = "#{dir}/#{ruby_version[/^\d+\.\d+/]}/#{EXTENSION_NAME}.so"
73+
so_file = "#{dir}/#{ruby_version[/^\d+\.\d+/]}/#{EXT_NAME}.so"
6974
if File.exists?(so_file)
7075
sh "#{prefix}-strip -S #{so_file}"
7176
end
@@ -94,7 +99,11 @@ end
9499

95100
namespace :build do
96101

97-
build_deps = [:clean]
102+
task :mkdir_pkg do
103+
mkdir_p 'pkg'
104+
end
105+
106+
build_deps = [:clean, 'build:mkdir_pkg']
98107
build_deps << :compile if Concurrent.jruby?
99108

100109
desc "Build #{CORE_GEM} into the pkg directory"
@@ -103,18 +112,24 @@ namespace :build do
103112
sh 'mv *.gem pkg/'
104113
end
105114

115+
desc "Build #{EDGE_GEM} into the pkg directory"
116+
task :edge => 'build:mkdir_pkg' do
117+
sh "gem build #{EDGE_GEMSPEC.name}.gemspec"
118+
sh 'mv *.gem pkg/'
119+
end
120+
106121
unless Concurrent.jruby?
107-
desc "Build #{EXTENSION_GEM} into the pkg directory"
108-
task :ext => [:clean] do
122+
desc "Build #{EXT_GEM} into the pkg directory"
123+
task :ext => build_deps do
109124
sh "gem build #{EXT_GEMSPEC.name}.gemspec"
110125
sh 'mv *.gem pkg/'
111126
end
112127
end
113128

114129
if Concurrent.allow_c_extensions?
115130
desc "Build #{NATIVE_GEM} into the pkg directory"
116-
task :native do
117-
sh "gem compile pkg/#{EXTENSION_GEM}"
131+
task :native => 'build:mkdir_pkg' do
132+
sh "gem compile pkg/#{EXT_GEM}"
118133
sh 'mv *.gem pkg/'
119134
end
120135
end
@@ -124,8 +139,8 @@ if Concurrent.jruby?
124139
desc 'Build JRuby-specific core gem (alias for `build:core`)'
125140
task :build => ['build:core']
126141
else
127-
desc 'Build core and extension gems'
128-
task :build => ['build:core', 'build:ext']
142+
desc 'Build core, extension, and edge gems'
143+
task :build => ['build:core', 'build:ext', 'build:edge']
129144
end
130145

131146
## the RSpec task that compiles extensions when available

concurrent-ruby-edge.gemspec

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
$:.push File.join(File.dirname(__FILE__), 'lib')
2+
3+
require 'concurrent/version'
4+
require 'concurrent/edge/version'
5+
6+
Gem::Specification.new do |s|
7+
s.name = 'concurrent-ruby-edge'
8+
s.version = Concurrent::Edge::VERSION
9+
s.platform = Gem::Platform::RUBY
10+
s.authors = ["Jerry D'Antonio", 'The Ruby Concurrency Team']
11+
12+
s.homepage = 'http://www.concurrent-ruby.com'
13+
s.summary = 'Experimental features and additions to the concurrent-ruby gem. Minimally tested and documented.'
14+
s.license = 'MIT'
15+
s.date = Time.now.strftime('%Y-%m-%d')
16+
17+
s.description = <<-EOF
18+
Experimental features and additions to the concurrent-ruby gem.
19+
Minimally tested and documented.
20+
Please see http://concurrent-ruby.com for more information.
21+
EOF
22+
23+
s.files = Dir['lib/concurrent/edge.rb', 'lib/concurrent/edge/**/*.rb']
24+
s.files += Dir['lib/concurrent/actor.rb', 'lib/concurrent/actor/**/*.rb']
25+
s.files += Dir['lib/concurrent/channel.rb', 'lib/concurrent/channel/**/*.rb']
26+
s.extra_rdoc_files = Dir['README*', 'LICENSE*']
27+
s.require_paths = ['lib']
28+
29+
s.required_ruby_version = '>= 1.9.3'
30+
31+
s.add_runtime_dependency 'concurrent-ruby', "~> #{Concurrent::VERSION}"
32+
end

concurrent-ruby.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
1818
Inspired by Erlang, Clojure, Go, JavaScript, actors, and classic concurrency patterns.
1919
EOF
2020

21-
s.files = Dir['lib/**/*.rb']
21+
s.files = Dir['lib/**/*.rb'].delete_if{|path| path =~ /actor|channel|edge/}
2222
s.extra_rdoc_files = Dir['README*', 'LICENSE*', 'CHANGELOG*']
2323
s.require_paths = ['lib']
2424

lib/concurrent.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
require 'concurrent/configuration'
44

5-
require 'concurrent/actor'
65
require 'concurrent/atomics'
7-
require 'concurrent/channels'
86
require 'concurrent/collections'
97
require 'concurrent/errors'
108
require 'concurrent/executors'

lib/concurrent/actress.rb

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

lib/concurrent/channel.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require 'concurrent/channel/blocking_ring_buffer'
2+
require 'concurrent/channel/buffered_channel'
3+
require 'concurrent/channel/channel'
4+
require 'concurrent/channel/ring_buffer'
5+
require 'concurrent/channel/unbuffered_channel'
6+
require 'concurrent/channel/waitable_list'

lib/concurrent/channels.rb

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

0 commit comments

Comments
 (0)