Skip to content

Commit 77b70e1

Browse files
committed
Moved C extensions into a companion gem.
1 parent df20680 commit 77b70e1

23 files changed

+31
-528
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ group :development do
88
end
99

1010
group :testing do
11+
gem 'concurrent-ruby-ext', :platforms => :mri, git: 'https://github.com/ruby-concurrency/concurrent-ruby-ext', branch: 'master'
1112
gem 'rspec', '~> 3.0.0'
1213
gem 'simplecov', '~> 0.8.2', :require => false
1314
gem 'coveralls', '~> 0.7.0', :require => false

README.md

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
### Supported Ruby versions
3939

4040
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.
41+
This gem should be fully compatible with any interpreter that is compliant with Ruby 1.9.3 or newer.
4442

4543
## Features & Documentation
4644

@@ -96,30 +94,7 @@ Lower-level abstractions mainly used as building blocks.
9694
* [thread-local variables](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ThreadLocalVar.html)
9795
* [software transactional memory](./doc/tvar.md) (TVar)
9896

99-
100-
101-
## Installing and Building
102-
103-
This gem includes several platform-specific optimizations. To reduce the possibility of
104-
compilation errors, we provide pre-compiled gem packages for several platforms as well
105-
as a pure-Ruby build. Installing the gem should be no different than installing any other
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)
121-
122-
### Installing
97+
## Installing
12398

12499
```shell
125100
gem install concurrent-ruby
@@ -133,31 +108,28 @@ gem 'concurrent-ruby'
133108

134109
and run `bundle install` from your shell.
135110

136-
### Building
111+
### Installing Optional C Extensions (MRI)
137112

138-
Because we provide pre-compiled gem builds, users should never need to build the gem manually.
139-
The build process for this gem is completely automated using open source tools. All of
140-
the automation components are available in the [ruby-concurrency/rake-compiler-dev-box](https://github.com/ruby-concurrency/rake-compiler-dev-box)
141-
GitHub repository.
113+
For improved performance on MRI a compantion gem with called `concurrent-ruby-ext` is provided. When the
114+
extensions are installed `concurrent-ruby` will detect their presence and automatically load them.
142115

143-
This gem will compile native C code under MRI and native Java code under JRuby. It is
144-
also possible to build a pure-Ruby version. All builds have identical functionality.
145-
The only difference is performance. Additionally, pure-Ruby classes are always available,
146-
even when using the native optimizations. Please see the [documentation](http://ruby-concurrency.github.io/concurrent-ruby/)
147-
for more details.
116+
```shell
117+
gem install concurrent-ruby-ext
118+
```
148119

149-
To build and package the gem using MRI or JRuby, install the necessary build dependencies and run:
120+
or add the following line to Gemfile:
150121

151-
```shell
152-
bundle exec rake compile
153-
bundle exec rake build
122+
```ruby
123+
gem 'concurrent-ruby'-ext
154124
```
155125

156-
To build and package a pure-Ruby gem, on *any* platform and interpreter
157-
(including MRI and JRuby), run:
126+
and run `bundle install` from your shell.
158127

159-
```shell
160-
BUILD_PURE_RUBY='true' bundle exec rake build
128+
In your code make sure you require the extension gem **before** you require the core gem:
129+
130+
```ruby
131+
require 'concurrent_ext'
132+
require 'concurrent'
161133
```
162134

163135
## Maintainers

Rakefile

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,6 @@ if defined?(JRUBY_VERSION)
3434
ext.ext_dir = 'ext'
3535
end
3636

37-
elsif Concurrent.allow_c_extensions?
38-
39-
Rake::ExtensionTask.new(EXTENSION_NAME, GEMSPEC) do |ext|
40-
ext.ext_dir = "ext/#{EXTENSION_NAME}"
41-
ext.cross_compile = true
42-
ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
43-
end
44-
45-
ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
46-
platforms = {
47-
'x86-mingw32' => 'i686-w64-mingw32',
48-
'x64-mingw32' => 'x86_64-w64-mingw32'
49-
}
50-
platforms.each do |platform, prefix|
51-
task "copy:#{EXTENSION_NAME}:#{platform}:#{ruby_version}" do |t|
52-
%w[lib tmp/#{platform}/stage/lib].each do |dir|
53-
so_file = "#{dir}/#{ruby_version[/^\d+\.\d+/]}/#{EXTENSION_NAME}.so"
54-
if File.exists?(so_file)
55-
sh "#{prefix}-strip -S #{so_file}"
56-
end
57-
end
58-
end
59-
end
60-
end
6137
else
6238
task :clean
6339
task :compile
@@ -67,10 +43,7 @@ end
6743
Rake::Task[:clean].enhance do
6844
rm_rf 'pkg/classes'
6945
rm_rf 'tmp'
70-
rm_rf 'lib/1.9'
71-
rm_rf 'lib/2.0'
7246
rm_f Dir.glob('./lib/*.jar')
73-
rm_f Dir.glob('./**/*.bundle')
7447
end
7548

7649
begin

concurrent-ruby.gemspec

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,9 @@ Gem::Specification.new do |s|
2525
if defined?(JRUBY_VERSION)
2626
s.files += Dir['lib/concurrent_ruby_ext.jar']
2727
s.platform = 'java'
28-
elsif ! ENV['BUILD_PURE_RUBY']
29-
s.extensions = 'ext/concurrent_ruby_ext/extconf.rb'
30-
s.files += Dir['ext/**/*.{h,c,cpp}']
28+
else
29+
s.add_dependency 'ref', '~> 1.0.5'
3130
end
3231

3332
s.required_ruby_version = '>= 1.9.3'
34-
35-
unless defined?(JRUBY_VERSION)
36-
s.add_dependency 'ref', '~> 1.0.5'
37-
end
3833
end

ext/concurrent_ruby_ext/atomic_boolean.c

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

ext/concurrent_ruby_ext/atomic_boolean.h

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

ext/concurrent_ruby_ext/atomic_fixnum.c

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

ext/concurrent_ruby_ext/atomic_fixnum.h

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

ext/concurrent_ruby_ext/atomic_reference.c

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

0 commit comments

Comments
 (0)