Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c051b56abc8d
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 65630e70c8e0
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Nov 30, 2015

  1. Copy the full SHA
    70a6497 View commit details

Commits on Dec 1, 2015

  1. Merge pull request #3506 from lucasallan/thread-name

    [Ruby-2.3] - Implements Thread#name and Thread#name=
    enebo committed Dec 1, 2015
    Copy the full SHA
    65630e7 View commit details
Showing with 17 additions and 0 deletions.
  1. +17 −0 core/src/main/java/org/jruby/RubyThread.java
17 changes: 17 additions & 0 deletions core/src/main/java/org/jruby/RubyThread.java
Original file line number Diff line number Diff line change
@@ -105,6 +105,8 @@ public class RubyThread extends RubyObject implements ExecutionContext {

private static final Logger LOG = LoggerFactory.getLogger("RubyThread");

private volatile IRubyObject threadName;

/** The thread-like think that is actually executing */
private volatile ThreadLike threadImpl;

@@ -692,6 +694,17 @@ public IRubyObject pending_interrupt_p(ThreadContext context, IRubyObject[] args
}
}

@JRubyMethod(name = "name=", required = 1)
public IRubyObject setName(ThreadContext context, IRubyObject name) {
this.threadName = name;
return threadName;
}

@JRubyMethod(name = "name")
public IRubyObject getName(ThreadContext context) {
return this.threadName;
}

private boolean pendingInterruptInclude(IRubyObject err) {
Iterator<IRubyObject> iterator = pendingInterruptQueue.iterator();
while (iterator.hasNext()) {
@@ -1007,6 +1020,10 @@ public synchronized IRubyObject inspect() {
String cname = getMetaClass().getRealClass().getName();
part.append("#<").append(cname).append(":");
part.append(identityString());
if (threadName != null) {
part.append('@');
part.append(threadName.asJavaString());
}
part.append(' ');
part.append(status.toString().toLowerCase());
part.append('>');