File tree Expand file tree Collapse file tree 9 files changed +57
-26
lines changed Expand file tree Collapse file tree 9 files changed +57
-26
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ if defined?(JRUBY_VERSION)
3434 ext . ext_dir = 'ext'
3535 end
3636
37- elsif Concurrent . use_c_extensions ?
37+ elsif Concurrent . allow_c_extensions ?
3838
3939 Rake ::ExtensionTask . new ( EXTENSION_NAME , GEMSPEC ) do |ext |
4040 ext . ext_dir = "ext/#{ EXTENSION_NAME } "
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ def create_dummy_makefile
1212 end
1313end
1414
15- if defined? ( JRUBY_VERSION ) || ! Concurrent . use_c_extensions ?
15+ if defined? ( JRUBY_VERSION ) || ! Concurrent . allow_c_extensions ?
1616 create_dummy_makefile
1717 warn 'C optimizations are not supported on this version of Ruby.'
1818else
Original file line number Diff line number Diff line change 1+ require_relative '../../extension_helper'
2+ Concurrent . safe_require_c_extensions
3+
14module Concurrent
25
36 # @!macro [attach] atomic_boolean
Original file line number Diff line number Diff line change 1+ require_relative '../../extension_helper'
2+ Concurrent . safe_require_c_extensions
3+
14module Concurrent
25
36 # @!macro [attach] atomic_fixnum
Original file line number Diff line number Diff line change 1- require 'concurrent_ruby_ext '
2- require 'concurrent/atomic_reference/direct_update'
1+ require_relative '../../extension_helper '
2+ Concurrent . safe_require_java_extensions
33
4- module Concurrent
4+ if defined? ( Concurrent ::JavaAtomic )
5+ require 'concurrent/atomic_reference/direct_update'
56
6- # @!macro atomic_reference
7- class JavaAtomic
8- include Concurrent ::AtomicDirectUpdate
7+ module Concurrent
8+
9+ # @!macro atomic_reference
10+ class JavaAtomic
11+ include Concurrent ::AtomicDirectUpdate
12+ end
913 end
1014end
Original file line number Diff line number Diff line change 1- begin
2- require 'concurrent_ruby_ext'
3- rescue LoadError
4- # may be a Windows cross-compiled native gem
5- require "#{ RUBY_VERSION [ 0 ..2 ] } /concurrent_ruby_ext"
1+ require_relative '../../extension_helper'
2+
3+ if Concurrent . allow_c_extensions?
4+ begin
5+ require 'concurrent_ruby_ext'
6+ rescue LoadError
7+ # may be a Windows cross-compiled native gem
8+ require "#{ RUBY_VERSION [ 0 ..2 ] } /concurrent_ruby_ext"
9+ end
610end
711
812require 'concurrent/atomic_reference/direct_update'
@@ -14,19 +18,19 @@ module Concurrent
1418 class CAtomic
1519 include Concurrent ::AtomicDirectUpdate
1620 include Concurrent ::AtomicNumericCompareAndSetWrapper
17-
21+
1822 # @!method initialize
1923 # @!macro atomic_reference_method_initialize
20-
24+
2125 # @!method get
2226 # @!macro atomic_reference_method_get
23-
27+
2428 # @!method set
2529 # @!macro atomic_reference_method_set
26-
30+
2731 # @!method get_and_set
2832 # @!macro atomic_reference_method_get_and_set
29-
33+
3034 # @!method _compare_and_set
3135 # @!macro atomic_reference_method_compare_and_set
3236 end
Original file line number Diff line number Diff line change 11module Concurrent
2- VERSION = '0.7.0.rc2 '
2+ VERSION = '0.7.0.rc3 '
33end
Original file line number Diff line number Diff line change 1- require 'rbconfig'
2-
31module Concurrent
4- def self . use_c_extensions?
5- host_os = RbConfig ::CONFIG [ 'host_os' ]
6- ruby_name = RbConfig ::CONFIG [ 'ruby_install_name' ]
7- ( ruby_name =~ /^ruby$/i || host_os =~ /mswin32/i || host_os =~ /mingw32/i )
2+
3+ # @!visibility private
4+ def self . allow_c_extensions?
5+ defined? ( RUBY_ENGINE ) && RUBY_ENGINE == 'ruby'
6+ end
7+
8+ # @!visibility private
9+ def self . allow_c_native_class? ( clazz )
10+ allow_c_extensions? && defined? ( clazz )
11+ end
12+
13+ # @!visibility private
14+ def self . safe_require_c_extensions
15+ require 'concurrent_ruby_ext'
16+ rescue LoadError
17+ warn 'Attempted to load C extensions on unsupported platform. Continuing with pure-Ruby.'
18+ end
19+
20+ # @!visibility private
21+ def self . safe_require_java_extensions
22+ require 'concurrent_ruby_ext' if RUBY_PLATFORM == 'java'
23+ rescue LoadError
24+ warn 'Attempted to load Java extensions on unsupported platform. Continuing with pure-Ruby.'
825 end
926end
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def rbx?
2424 end
2525
2626 def use_c_extensions?
27- Concurrent . use_c_extensions ? # from extension_helper.rb
27+ Concurrent . allow_c_extensions ? # from extension_helper.rb
2828 end
2929
3030 def do_no_reset!
You can’t perform that action at this time.
0 commit comments