Module: Concurrent::Utility::NativeExtensionLoader
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Extended In:
| |
Defined in: | lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb |
Instance Attribute Summary
- #allow_c_extensions? ⇒ Boolean readonly
- #c_extensions_loaded? ⇒ Boolean readonly
- #java_extensions_loaded? ⇒ Boolean readonly private
Instance Method Summary
- #load_native_extensions
- #load_error_path(error) private
- #set_c_extensions_loaded private
- #set_java_extensions_loaded private
- #try_load_c_extension(path) private
Instance Attribute Details
#allow_c_extensions? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb', line 11
def allow_c_extensions? Concurrent.on_cruby? end
#c_extensions_loaded? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb', line 15
def c_extensions_loaded? defined?(@c_extensions_loaded) && @c_extensions_loaded end
#java_extensions_loaded? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb', line 50
def java_extensions_loaded? defined?(@java_extensions_loaded) && @java_extensions_loaded end
Instance Method Details
#load_error_path(error) (private)
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb', line 38
def load_error_path(error) if error.respond_to? :path error.path else error. .split(' -- ').last end end
#load_native_extensions
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb', line 19
def load_native_extensions if Concurrent.on_cruby? && !c_extensions_loaded? ['concurrent/concurrent_ruby_ext', "concurrent/#{RUBY_VERSION[0..2]}/concurrent_ruby_ext" ].each { |p| try_load_c_extension p } end if Concurrent.on_jruby? && !java_extensions_loaded? begin require 'concurrent/concurrent_ruby.jar' set_java_extensions_loaded rescue LoadError => e raise e, "Java extensions are required for JRuby.\n" + e., e.backtrace end end end
#set_c_extensions_loaded (private)
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb', line 46
def set_c_extensions_loaded @c_extensions_loaded = true end
#set_java_extensions_loaded (private)
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb', line 54
def set_java_extensions_loaded @java_extensions_loaded = true end
#try_load_c_extension(path) (private)
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb', line 58
def try_load_c_extension(path) require path set_c_extensions_loaded rescue LoadError => e if load_error_path(e) == path # move on with pure-Ruby implementations # TODO (pitr-ch 12-Jul-2018): warning on verbose? else raise e end end