Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 13666ff

Browse files
committed
Use COW list for event hooks, to avoid synchronization.
See jruby#1142. This supercedes a fix there. I opted to use CopyOnWriteArrayList here for two reasons: * It does not require synchronization, neither for access nor iter * EventHooks should are only added or removed rarely
1 parent 59dd88a commit 13666ff

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

core/src/main/java/org/jruby/Ruby.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,7 @@
134134
import java.security.AccessControlException;
135135
import java.security.SecureRandom;
136136
import java.util.*;
137-
import java.util.concurrent.Callable;
138-
import java.util.concurrent.ConcurrentHashMap;
139-
import java.util.concurrent.ExecutorService;
140-
import java.util.concurrent.SynchronousQueue;
141-
import java.util.concurrent.ThreadPoolExecutor;
142-
import java.util.concurrent.TimeUnit;
137+
import java.util.concurrent.*;
143138
import java.util.concurrent.atomic.AtomicInteger;
144139
import java.util.concurrent.atomic.AtomicLong;
145140
import java.util.regex.Pattern;
@@ -4546,7 +4541,7 @@ public CallbackFactory callbackFactory(Class<?> type) {
45464541

45474542
private final RubySymbol.SymbolTable symbolTable = new RubySymbol.SymbolTable(this);
45484543

4549-
private final List<EventHook> eventHooks = new Vector<EventHook>();
4544+
private final List<EventHook> eventHooks = new CopyOnWriteArrayList<EventHook>();
45504545
private boolean hasEventHooks;
45514546
private boolean globalAbortOnExceptionEnabled = false;
45524547
private boolean doNotReverseLookupEnabled = false;

0 commit comments

Comments
 (0)