Permalink
Browse files

Associate non-Ruby threads in ThreadService for JRUBY-3742: Java nati…

…ve threads are not added to ThreadService.rubyThreadMap after being adopted.
  • Loading branch information...
1 parent 08c88f4 commit 3a3c8cd43442ed4d5f5a296c64d0400bd6e96fb1 @headius headius committed May 1, 2010
Showing with 22 additions and 1 deletion.
  1. +1 −0 src/org/jruby/RubyThread.java
  2. +21 −1 src/org/jruby/internal/runtime/ThreadService.java
@@ -228,6 +228,7 @@ private static RubyThread adoptThread(final IRubyObject recv, Thread t, Block bl
rubyThread.threadImpl = new NativeThread(rubyThread, t);
ThreadContext context = runtime.getThreadService().registerNewThread(rubyThread);
+ runtime.getThreadService().associateThread(t, rubyThread);
context.preAdoptThread();
@@ -38,7 +38,6 @@
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;
@@ -246,4 +245,25 @@ public synchronized void deliverEvent(Event event) {
// then deliver mail to the target
event.target.receiveMail(event);
}
+
+ /**
+ * Get the map from threadlike objects to RubyThread instances. Used mainly
+ * for testing purposes.
+ *
+ * @return The ruby thread map
+ */
+ public RubyThreadMap getRubyThreadMap() {
+ return rubyThreadMap;
+ }
+
+ /**
+ * Get the map from RubyThread objects to ThreadContext objects. Used for
+ * testing purposes.
+ *
+ * @return The thread context map
+ * @return
+ */
+ public Map getThreadContextMap() {
+ return threadContextMap;
+ }
}

0 comments on commit 3a3c8cd

Please sign in to comment.