From 8385158d35702ea43d9849df2a8bcd720d693cf9 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Mon, 25 Feb 2013 21:59:45 -0600 Subject: [PATCH] use native weakref implementation for ruby 2.0 --- lib/v8/weak.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/v8/weak.rb b/lib/v8/weak.rb index 89b02cf..4614798 100644 --- a/lib/v8/weak.rb +++ b/lib/v8/weak.rb @@ -3,11 +3,14 @@ module V8 # weak refs are broken on MRI 1.9 and merely slow on 1.8 # so we mitigate this by using the 'ref' gem. However, this # only mitigates the problem. Under heavy load, you will still - # get different or terminated objects being returned. bad stuff + # get different or terminated objects being returned. bad stuff. + # + # If you are having problems with this, an upgrade to 2.0 is *highly* + # recommended. # # for other platforms we just use the stdlib 'weakref' # implementation - if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' + if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION < '2.0.0' require 'ref' Ref = ::Ref::WeakReference WeakValueMap = ::Ref::WeakValueMap