Skip to content

Commit

Permalink
Remove start from ThreadLike since only Ruby threads can start
Browse files Browse the repository at this point in the history
This also calls start on the native thread directly, rather than
by traversing the native thread object.
  • Loading branch information
headius committed Apr 14, 2020
1 parent f46024f commit 0c8b19d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/RubyThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,12 @@ private Thread startThread(ThreadContext context, Runnable runnable) throws Rais
try {
Thread thread = new Thread(runnable);
thread.setDaemon(true);

this.file = context.getFile();
this.line = context.getLine();

initThreadName(runtime, thread, file, line);

threadImpl = new RubyNativeThread(this, thread);

addToCorrectThreadGroup(context);
Expand All @@ -633,6 +636,7 @@ private Thread startThread(ThreadContext context, Runnable runnable) throws Rais
// copy parent thread's interrupt masks
copyInterrupts(context, context.getThread().interruptMaskStack, this.interruptMaskStack);

// start the native thread
thread.start();

// We yield here to hopefully permit the target thread to schedule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public AdoptedNativeThread(RubyThread rubyThread, Thread nativeThread) {
this.nativeThread = new WeakReference<>(nativeThread);
}

public void start() {
throw new RuntimeException("BUG: can't start an adopted thread");
}

public void interrupt() {
Thread thread = getThread();
if (thread != null) thread.interrupt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ public RubyNativeThread(RubyThread rubyThread, Thread nativeThread) {
this.rubyName = null;
}

public void start() {
thread.start();
}

public void interrupt() {
thread.interrupt();
}
Expand Down
5 changes: 0 additions & 5 deletions core/src/main/java/org/jruby/internal/runtime/ThreadLike.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import java.util.concurrent.ExecutionException;

public interface ThreadLike {
public void start();

public void interrupt();

public boolean isAlive();
Expand All @@ -58,9 +56,6 @@ public interface ThreadLike {
public String getReportName();

ThreadLike DUMMY = new ThreadLike() {
@Override
public void start() {}

@Override
public void interrupt() {}

Expand Down

0 comments on commit 0c8b19d

Please sign in to comment.