Skip to content

Commit

Permalink
switching to a less-blocking COW list fixes mutex
Browse files Browse the repository at this point in the history
seems to resolve GH-5520
  • Loading branch information
kares committed Dec 15, 2018
1 parent ba2027a commit badc041
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions core/src/main/java/org/jruby/RubyThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@
import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
Expand Down Expand Up @@ -161,7 +158,7 @@ public class RubyThread extends RubyObject implements ExecutionContext {
//private volatile boolean handleInterrupt = true;

/** Stack of interrupt masks active for this thread */
private final List<RubyHash> interruptMaskStack = Collections.synchronizedList(new ArrayList<RubyHash>());
private final List<RubyHash> interruptMaskStack = new CopyOnWriteArrayList<>();

/** Thread-local tuple used for sleeping (semaphore, millis, nanos) */
private final SleepTask2 sleepTask = new SleepTask2();
Expand Down Expand Up @@ -345,12 +342,7 @@ private int pendingInterruptCheckMask(ThreadContext context, IRubyObject err) {
List<IRubyObject> ancestors = getMetaClass(err).getAncestorList();
int ancestorsLen = ancestors.size();

List<RubyHash> maskStack = interruptMaskStack;
int maskStackLen = maskStack.size();

for (int i = 0; i < maskStackLen; i++) {
RubyHash mask = maskStack.get(maskStackLen - (i + 1));

for (RubyHash mask : interruptMaskStack) {
for (int j = 0; j < ancestorsLen; j++) {
IRubyObject klass = ancestors.get(j);
IRubyObject sym;
Expand Down

0 comments on commit badc041

Please sign in to comment.