Skip to content

Commit

Permalink
Merge pull request #7 from nate/bugfix/ruby-1-8-7-detection
Browse files Browse the repository at this point in the history
Fix ruby engine detection such that it detects Ruby 1.8.7
  • Loading branch information
headius committed Oct 1, 2013
2 parents d74ed31 + 79ad982 commit b035720
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/thread_safe.rb
Expand Up @@ -28,7 +28,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
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

0 comments on commit b035720

Please sign in to comment.