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: b56c170a9c56
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 770be9e65a1a
Choose a head ref
  • 4 commits
  • 5 files changed
  • 1 contributor

Commits on Mar 13, 2015

  1. [Truffle] We can now use a proper Queue as a Channel!

    * Translate nil to undefined as Mutex#sleep accepts nil
      but Kernerl#sleep does not.
    eregon committed Mar 13, 2015
    Copy the full SHA
    d81820b View commit details
  2. Copy the full SHA
    c5d062c View commit details
  3. Copy the full SHA
    2bcd3cf View commit details
  4. Copy the full SHA
    770be9e View commit details
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/thread/join_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -148,18 +148,29 @@ public JoinNode(JoinNode prev) {
}

@Specialization
public RubyThread join(RubyThread self, UndefinedPlaceholder timeout) {
public RubyThread join(RubyThread thread, UndefinedPlaceholder timeout) {
notDesignedForCompilation();

self.join();
return self;
thread.join();
return thread;
}

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

if (self.join(timeout)) {
return joinMillis(thread, timeout * 1000);
}

@Specialization
public Object join(RubyThread thread, double timeout) {
notDesignedForCompilation();

return joinMillis(thread, (int) (timeout * 1000.0));
}

private Object joinMillis(RubyThread self, int timeoutInMillis) {
if (self.join(timeoutInMillis)) {
return self;
} else {
return getContext().getCoreLibrary().getNilObject();
Original file line number Diff line number Diff line change
@@ -43,6 +43,8 @@ public class RubyThread extends RubyBasicObject {

private String name;

/** We use this instead of {@link Thread#join()} since we don't always have a reference
* to the {@link Thread} and we want to handle cases where the Thread did not start yet. */
private final CountDownLatch finished = new CountDownLatch(1);

private volatile Thread thread;
@@ -99,7 +101,7 @@ public void run(final RubyContext context, Node currentNode, String info, Runnab
} catch (RaiseException e) {
exception = e.getRubyException();
} catch (ReturnException e) {
exception = getContext().getCoreLibrary().unexpectedReturn(currentNode);
exception = context.getCoreLibrary().unexpectedReturn(currentNode);
} finally {
cleanup(context);
}
@@ -108,7 +110,7 @@ public void run(final RubyContext context, Node currentNode, String info, Runnab
// Only used by the main thread which cannot easily wrap everything inside a try/finally.
public void cleanup(RubyContext context) {
status = Status.ABORTING;
context.getThreadManager().leaveGlobalLock();
manager.leaveGlobalLock();
context.getSafepointManager().leaveThread();
manager.unregisterThread(this);

@@ -123,7 +125,7 @@ public void setRootThread(Thread thread) {
}

public void join() {
getContext().getThreadManager().runUntilResult(new BlockingActionWithoutGlobalLock<Boolean>() {
manager.runUntilResult(new BlockingActionWithoutGlobalLock<Boolean>() {
@Override
public Boolean block() throws InterruptedException {
finished.await();
@@ -136,11 +138,11 @@ public Boolean block() throws InterruptedException {
}
}

public boolean join(final int timeout) {
final boolean joined = getContext().getThreadManager().runOnce(new BlockingActionWithoutGlobalLock<Boolean>() {
public boolean join(final int timeoutInMillis) {
final boolean joined = manager.runOnce(new BlockingActionWithoutGlobalLock<Boolean>() {
@Override
public Boolean block() throws InterruptedException {
return finished.await(timeout, TimeUnit.SECONDS);
return finished.await(timeoutInMillis, TimeUnit.MILLISECONDS);
}
});

2 changes: 2 additions & 0 deletions truffle/src/main/ruby/core/rubinius/common/mutex.rb
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ def synchronize
def sleep(duration=undefined)
if duration.kind_of?(Numeric) && duration < 0
raise ArgumentError, "time interval must be positive"
elsif duration == nil
duration = undefined
end

unlock
4 changes: 0 additions & 4 deletions truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -9,10 +9,6 @@
# These are implemented just to get other stuff working - we'll go back and
# implement these properly later.

# Here otherwise it causes problems for RubySpec
class Channel
end

class IO
def external_encoding
@external