|
17 | 17 | import org.truffleruby.annotations.SuppressFBWarnings;
|
18 | 18 | import org.truffleruby.core.thread.RubyThread;
|
19 | 19 | import org.truffleruby.core.thread.ThreadManager;
|
20 |
| -import org.truffleruby.language.control.KillException; |
21 | 20 | import org.truffleruby.language.control.RaiseException;
|
22 | 21 |
|
23 | 22 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
@@ -73,7 +72,6 @@ public ReferenceProcessingService<R, T> service() {
|
73 | 72 | public static class ReferenceProcessor {
|
74 | 73 | protected final ReferenceQueue<Object> processingQueue = new ReferenceQueue<>();
|
75 | 74 |
|
76 |
| - private volatile boolean shutdown = false; |
77 | 75 | protected RubyThread processingThread;
|
78 | 76 | protected final RubyContext context;
|
79 | 77 |
|
@@ -121,40 +119,13 @@ protected void createProcessingThread(ReferenceProcessingService<?, ?> service)
|
121 | 119 |
|
122 | 120 | threadManager.initialize(newThread, DummyNode.INSTANCE, THREAD_NAME, sharingReason, () -> {
|
123 | 121 | while (true) {
|
124 |
| - final PhantomProcessingReference<?, ?> reference = threadManager |
125 |
| - .runUntilResult(DummyNode.INSTANCE, () -> { |
126 |
| - try { |
127 |
| - return (PhantomProcessingReference<?, ?>) processingQueue.remove(); |
128 |
| - } catch (InterruptedException interrupted) { |
129 |
| - if (shutdown) { |
130 |
| - throw new KillException(DummyNode.INSTANCE); |
131 |
| - } else { |
132 |
| - throw interrupted; |
133 |
| - } |
134 |
| - } |
135 |
| - }); |
| 122 | + final PhantomProcessingReference<?, ?> reference = threadManager.runUntilResult(DummyNode.INSTANCE, |
| 123 | + () -> (PhantomProcessingReference<?, ?>) processingQueue.remove()); |
136 | 124 | reference.service().processReference(context, language, reference);
|
137 | 125 | }
|
138 | 126 | });
|
139 | 127 | }
|
140 | 128 |
|
141 |
| - public boolean shutdownProcessingThread() { |
142 |
| - final Thread javaThread = processingThread == null ? null : processingThread.thread; |
143 |
| - if (javaThread == null) { |
144 |
| - return false; |
145 |
| - } |
146 |
| - |
147 |
| - shutdown = true; |
148 |
| - javaThread.interrupt(); |
149 |
| - |
150 |
| - context.getThreadManager().runUntilResultKeepStatus(DummyNode.INSTANCE, t -> t.join(1000), javaThread); |
151 |
| - return true; |
152 |
| - } |
153 |
| - |
154 |
| - public RubyThread getProcessingThread() { |
155 |
| - return processingThread; |
156 |
| - } |
157 |
| - |
158 | 129 | @TruffleBoundary
|
159 | 130 | protected final void drainReferenceQueues() {
|
160 | 131 | final RubyLanguage language = context.getLanguageSlow();
|
|
0 commit comments