Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ruby engine detection such that it detects Ruby 1.8.7 #7

Merged
merged 1 commit into from
Oct 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/thread_safe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Array < ::Array
class Hash < ::Hash
include JRuby::Synchronized
end
elsif defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby'
elsif !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby'
# Because MRI never runs code in parallel, the existing
# non-thread-safe structures should usually work fine.
Array = ::Array
Expand Down
7 changes: 5 additions & 2 deletions lib/thread_safe/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ module ThreadSafe
autoload :AtomicReferenceCacheBackend, 'thread_safe/atomic_reference_cache_backend'
autoload :SynchronizedCacheBackend, 'thread_safe/synchronized_cache_backend'

ConcurrentCacheBackend =
case defined?(RUBY_ENGINE) && RUBY_ENGINE
ConcurrentCacheBackend = if defined?(RUBY_ENGINE)
case RUBY_ENGINE
when 'jruby'; JRubyCacheBackend
when 'ruby'; MriCacheBackend
when 'rbx'; AtomicReferenceCacheBackend
else
warn 'ThreadSafe: unsupported Ruby engine, using a fully synchronized ThreadSafe::Cache implementation' if $VERBOSE
SynchronizedCacheBackend
end
else
MriCacheBackend
end

class Cache < ConcurrentCacheBackend
KEY_ERROR = defined?(KeyError) ? KeyError : IndexError # there is no KeyError in 1.8 mode
Expand Down