mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
GitOrigin-RevId: 4c43f584bc04bce63ca28bc55a91e1891e21b546
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d1245e2a4b
commit
da6f32743f
+2
-1
@@ -337,7 +337,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
service.shutdownAppScheduledExecutorService();
|
||||
|
||||
super.dispose();
|
||||
Disposer.dispose(myLastDisposable); // dispose it last
|
||||
Disposer.dispose(myLastDisposable);
|
||||
|
||||
if (gatherStatistics) {
|
||||
//noinspection TestOnlyProblems
|
||||
@@ -1130,6 +1130,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String id() {
|
||||
Class<?> aClass = getClass();
|
||||
String name = aClass.getName();
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util.concurrency;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -27,7 +13,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* It starts the background thread which polls the queue for tasks ready to run and sends them to the appropriate executor.
|
||||
* The {@link #shutdown()} must be called before disposal.
|
||||
*/
|
||||
class AppDelayQueue extends DelayQueue<SchedulingWrapper.MyScheduledFutureTask> {
|
||||
final class AppDelayQueue extends DelayQueue<SchedulingWrapper.MyScheduledFutureTask<?>> {
|
||||
private static final Logger LOG = Logger.getInstance(AppDelayQueue.class);
|
||||
private final Thread scheduledToPooledTransferrer;
|
||||
private final AtomicBoolean shutdown = new AtomicBoolean();
|
||||
@@ -37,7 +23,7 @@ class AppDelayQueue extends DelayQueue<SchedulingWrapper.MyScheduledFutureTask>
|
||||
scheduledToPooledTransferrer = new Thread(() -> {
|
||||
while (!shutdown.get()) {
|
||||
try {
|
||||
final SchedulingWrapper.MyScheduledFutureTask task = take();
|
||||
SchedulingWrapper.MyScheduledFutureTask<?> task = take();
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("Took "+BoundedTaskExecutor.info(task));
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ public final class AppScheduledExecutorService extends SchedulingWrapper {
|
||||
mainLock.lock();
|
||||
Set workers;
|
||||
try {
|
||||
HashSet workersField = ReflectionUtil.getField(executor.getClass(), executor, HashSet.class, "workers");
|
||||
Set workersField = ReflectionUtil.getField(executor.getClass(), executor, HashSet.class, "workers");
|
||||
workers = new HashSet(workersField); // to be able to iterate thread-safely outside the lock
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
package com.intellij.util.concurrency;
|
||||
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -23,7 +22,7 @@ class SchedulingWrapper implements ScheduledExecutorService {
|
||||
@NotNull final ExecutorService backendExecutorService;
|
||||
final AppDelayQueue delayQueue;
|
||||
|
||||
SchedulingWrapper(@NotNull final ExecutorService backendExecutorService, @NotNull AppDelayQueue delayQueue) {
|
||||
SchedulingWrapper(@NotNull ExecutorService backendExecutorService, @NotNull AppDelayQueue delayQueue) {
|
||||
this.delayQueue = delayQueue;
|
||||
if (backendExecutorService instanceof ScheduledExecutorService) {
|
||||
throw new IllegalArgumentException("backendExecutorService: "+backendExecutorService+" is already ScheduledExecutorService");
|
||||
@@ -56,15 +55,20 @@ class SchedulingWrapper implements ScheduledExecutorService {
|
||||
|
||||
@NotNull
|
||||
List<Runnable> cancelAndRemoveTasksFromQueue() {
|
||||
List<MyScheduledFutureTask> result = ContainerUtil.filter(delayQueue, task -> {
|
||||
List<MyScheduledFutureTask<?>> result = new ArrayList<>();
|
||||
for (MyScheduledFutureTask<?> task : delayQueue) {
|
||||
if (task.getBackendExecutorService() == backendExecutorService) {
|
||||
task.cancel(false);
|
||||
return true;
|
||||
result.add(task);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
delayQueue.removeAll(new HashSet<>(result));
|
||||
//noinspection unchecked
|
||||
}
|
||||
|
||||
if (result.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
delayQueue.removeAll(result);
|
||||
//noinspection unchecked,rawtypes
|
||||
return (List)result;
|
||||
}
|
||||
|
||||
@@ -81,8 +85,8 @@ class SchedulingWrapper implements ScheduledExecutorService {
|
||||
@Override
|
||||
public boolean awaitTermination(long timeout, @NotNull TimeUnit unit) throws InterruptedException {
|
||||
if (!isShutdown()) throw new IllegalStateException("must await termination after shutdown() or shutdownNow() only");
|
||||
List<MyScheduledFutureTask> tasks = new ArrayList<>(delayQueue);
|
||||
for (MyScheduledFutureTask task : tasks) {
|
||||
List<MyScheduledFutureTask<?>> tasks = new ArrayList<>(delayQueue);
|
||||
for (MyScheduledFutureTask<?> task : tasks) {
|
||||
if (task.getBackendExecutorService() != backendExecutorService) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user