Skip to content

Commit

Permalink
[Truffle] Thread#join: return nil if Thread did not join in time.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Mar 13, 2015
1 parent 9c33101 commit b56c170
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/thread/join_tags.txt
@@ -1,7 +1,2 @@
fails:Thread#join returns the thread when it is finished
fails:Thread#join returns the thread when it is finished when given a timeout
fails:Thread#join returns nil if it is not finished when given a timeout
fails:Thread#join accepts a floating point timeout length
fails:Thread#join raises any exceptions encountered in the thread body
fails:Thread#join returns the dead thread
fails:Thread#join raises any uncaught exception encountered in ensure block
Expand Up @@ -156,11 +156,14 @@ public RubyThread join(RubyThread self, UndefinedPlaceholder timeout) {
}

@Specialization
public RubyThread join(RubyThread self, int timeout) {
public Object join(RubyThread self, int timeout) {
notDesignedForCompilation();

self.join(timeout);
return self;
if (self.join(timeout)) {
return self;
} else {
return getContext().getCoreLibrary().getNilObject();
}
}

}
Expand Down
Expand Up @@ -136,7 +136,7 @@ public Boolean block() throws InterruptedException {
}
}

public void join(final int timeout) {
public boolean join(final int timeout) {
final boolean joined = getContext().getThreadManager().runOnce(new BlockingActionWithoutGlobalLock<Boolean>() {
@Override
public Boolean block() throws InterruptedException {
Expand All @@ -147,6 +147,8 @@ public Boolean block() throws InterruptedException {
if (joined && exception != null) {
throw new RaiseException(exception);
}

return joined;
}

public void interrupt() {
Expand Down

0 comments on commit b56c170

Please sign in to comment.