Skip to content

Commit

Permalink
[Truffle] Use a finer-grained lock to control access to truffleBridge.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Mar 9, 2015
1 parent 475e741 commit 100802c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
Expand Up @@ -907,12 +907,13 @@ public JITCompiler getJITCompiler() {
return jitCompiler;
}

public synchronized TruffleBridge getTruffleBridge() {
if (truffleBridge == null) {
truffleBridge = loadTruffleBridge();
public TruffleBridge getTruffleBridge() {
synchronized (truffleBridgeMutex) {
if (truffleBridge == null) {
truffleBridge = loadTruffleBridge();
}
return truffleBridge;
}

return truffleBridge;
}

private TruffleBridge loadTruffleBridge() {
Expand Down Expand Up @@ -943,9 +944,11 @@ private TruffleBridge loadTruffleBridge() {
return truffleBridge;
}

public synchronized void shutdownTruffleBridge() {
if (truffleBridge != null) {
truffleBridge.shutdown();
public void shutdownTruffleBridge() {
synchronized (truffleBridgeMutex) {
if (truffleBridge != null) {
truffleBridge.shutdown();
}
}
}

Expand Down Expand Up @@ -4912,6 +4915,7 @@ public FilenoUtil getFilenoUtil() {
private final JITCompiler jitCompiler;

private TruffleBridge truffleBridge;
private final Object truffleBridgeMutex = new Object();

// Note: this field and the following static initializer
// must be located be in this order!
Expand Down

0 comments on commit 100802c

Please sign in to comment.