RDCT-1642 resetThreadContext() in FlushQueue.flushNow()

GitOrigin-RevId: 3cfc25ea5390565f3b57e1944de37f15dff405a6
This commit is contained in:
Artem.Bukhonov
2024-08-20 21:38:59 +02:00
committed by intellij-monorepo-bot
parent 67d658ecc5
commit cff13bc18f

View File

@@ -2,7 +2,9 @@
package com.intellij.openapi.application.impl;
import com.intellij.concurrency.ContextAwareRunnable;
import com.intellij.concurrency.ThreadContext;
import com.intellij.diagnostic.EventWatcher;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
@@ -26,22 +28,25 @@ final class FlushQueue {
private final BulkArrayQueue<RunnableInfo> myQueue = new BulkArrayQueue<>(); //guarded by getQueueLock()
private void flushNow() {
ThreadingAssertions.assertEventDispatchThread();
synchronized (getQueueLock()) {
FLUSHER_SCHEDULED = false;
}
long startTime = System.currentTimeMillis();
while (true) {
RunnableInfo info = pollNextEvent();
if (info == null) {
break;
try (AccessToken ignored = ThreadContext.resetThreadContext()) {
ThreadingAssertions.assertEventDispatchThread();
synchronized (getQueueLock()) {
FLUSHER_SCHEDULED = false;
}
runNextEvent(info);
if (InvocationUtil.priorityEventPending() || System.currentTimeMillis() - startTime > 5) {
synchronized (getQueueLock()) {
requestFlush();
long startTime = System.currentTimeMillis();
while (true) {
RunnableInfo info = pollNextEvent();
if (info == null) {
break;
}
runNextEvent(info);
if (InvocationUtil.priorityEventPending() || System.currentTimeMillis() - startTime > 5) {
synchronized (getQueueLock()) {
requestFlush();
}
break;
}
break;
}
}
}