Permalink
Browse files

Fixes for the fixes for JRUBY-3742: Java native threads are not added…

… to ThreadService.rubyThreadMap after being adopted.

* Make the weak RubyThreadMap actually use the reference queue (doh!)
* Revert the threadContextMap to a weak map (doh!)
  • Loading branch information...
1 parent bdb3995 commit 08c88f45e6f077275a2dd529010f25290e7433ce @headius headius committed Apr 30, 2010
@@ -108,7 +108,7 @@ public RubyThread get(Object key) {
public RubyThread put(Object key, RubyThread value) {
cleanup();
key = nullKey(key);
- return map.put(new RubyThreadWeakReference(key, value), value);
+ return map.put(new RubyThreadWeakReference(key, queue, value), value);
}
public RubyThread remove(Object key) {
@@ -34,10 +34,12 @@
import java.util.concurrent.locks.ReentrantLock;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Hashtable;
+import java.util.WeakHashMap;
import java.util.concurrent.Future;
import org.jruby.Ruby;
import org.jruby.RubyThread;
@@ -66,7 +68,7 @@ public ThreadService(Ruby runtime) {
this.rubyThreadGroup = Thread.currentThread().getThreadGroup();
}
- this.threadContextMap = new Hashtable<RubyThread, ThreadContext>();
+ this.threadContextMap = Collections.synchronizedMap(new WeakHashMap<RubyThread, ThreadContext>());
this.rubyThreadMap = new RubyThreadMap(threadContextMap);
// Must be called from main thread (it is currently, but this bothers me)

0 comments on commit 08c88f4

Please sign in to comment.