mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -36,7 +36,7 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutorService;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutor;
|
||||
import com.intellij.util.containers.Queue;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -56,7 +56,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.DocumentCommitThread");
|
||||
private static final String NAME = "Document commit thread";
|
||||
|
||||
private final ExecutorService executor = new BoundedTaskExecutorService(PooledThreadExecutor.INSTANCE, JobSchedulerImpl.CORES_COUNT, this);
|
||||
private final ExecutorService executor = new BoundedTaskExecutor(PooledThreadExecutor.INSTANCE, JobSchedulerImpl.CORES_COUNT, this);
|
||||
|
||||
private final Queue<CommitTask> documentsToCommit = new Queue<CommitTask>(10);
|
||||
private final List<CommitTask> documentsToApplyInEDT = new ArrayList<CommitTask>(10); // guarded by documentsToCommit
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ import com.intellij.openapi.vfs.newvfs.impl.StubVirtualFile;
|
||||
import com.intellij.psi.SingleRootFileViewProvider;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutorService;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutor;
|
||||
import com.intellij.util.containers.ConcurrentPackedBitsArray;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.URLUtil;
|
||||
@@ -346,7 +346,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent
|
||||
System.out.println(message + " - "+Thread.currentThread());
|
||||
}
|
||||
|
||||
private final BoundedTaskExecutorService reDetectExecutor = new BoundedTaskExecutorService(PooledThreadExecutor.INSTANCE, 1, this);
|
||||
private final BoundedTaskExecutor reDetectExecutor = new BoundedTaskExecutor(PooledThreadExecutor.INSTANCE, 1, this);
|
||||
private final BlockingQueue<VirtualFile> filesToRedetect = new LinkedBlockingDeque<VirtualFile>();
|
||||
|
||||
private void awakeReDetectExecutor() {
|
||||
|
||||
+3
-2
@@ -48,7 +48,7 @@ import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutorService;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutor;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import gnu.trove.Equality;
|
||||
import gnu.trove.THashSet;
|
||||
@@ -100,7 +100,8 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt
|
||||
private final Alarm updateEncodingFromContent = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, this);
|
||||
private static final Key<Charset> CACHED_CHARSET_FROM_CONTENT = Key.create("CACHED_CHARSET_FROM_CONTENT");
|
||||
|
||||
private final BoundedTaskExecutorService changedDocumentExecutor = new BoundedTaskExecutorService(PooledThreadExecutor.INSTANCE, JobSchedulerImpl.CORES_COUNT, this);
|
||||
private final BoundedTaskExecutor changedDocumentExecutor =
|
||||
new BoundedTaskExecutor(PooledThreadExecutor.INSTANCE, JobSchedulerImpl.CORES_COUNT, this);
|
||||
|
||||
public EncodingManagerImpl(@NotNull EditorFactory editorFactory) {
|
||||
editorFactory.getEventMulticaster().addDocumentListener(new DocumentAdapter() {
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.vfs.VfsBundle;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutorService;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutor;
|
||||
import com.intellij.util.io.storage.HeavyProcessLatch;
|
||||
import gnu.trove.TLongObjectHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -43,7 +43,7 @@ import java.util.concurrent.ExecutorService;
|
||||
public class RefreshQueueImpl extends RefreshQueue implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.newvfs.RefreshQueueImpl");
|
||||
|
||||
private final ExecutorService myQueue = new BoundedTaskExecutorService(PooledThreadExecutor.INSTANCE, 1, this);
|
||||
private final ExecutorService myQueue = new BoundedTaskExecutor(PooledThreadExecutor.INSTANCE, 1, this);
|
||||
private final ProgressIndicator myRefreshIndicator = RefreshProgress.create(VfsBundle.message("file.synchronize.progress"));
|
||||
private final TLongObjectHashMap<RefreshSession> mySessions = new TLongObjectHashMap<RefreshSession>();
|
||||
private final FrequentEventDetector myEventCounter = new FrequentEventDetector(100, 100, FrequentEventDetector.Level.ERROR);
|
||||
|
||||
+3
-2
@@ -30,7 +30,7 @@ import com.intellij.openapi.vfs.newvfs.impl.FileNameCache;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.CompressionUtil;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutorService;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutor;
|
||||
import com.intellij.util.containers.ConcurrentIntObjectMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
@@ -280,7 +280,8 @@ public class FSRecords implements Forceable {
|
||||
@NotNull
|
||||
@Override
|
||||
protected ExecutorService createExecutor() {
|
||||
return new BoundedTaskExecutorService(PooledThreadExecutor.INSTANCE, 1);
|
||||
final ExecutorService backendExecutor = PooledThreadExecutor.INSTANCE;
|
||||
return new BoundedTaskExecutor(backendExecutor, 1);
|
||||
}
|
||||
}; // sources usually zipped with 4x ratio
|
||||
myContentHashesEnumerator = weHaveContentHashes ? new ContentHashesUtil.HashEnumerator(contentsHashesFile, storageLockContext): null;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutorService;
|
||||
import com.intellij.util.concurrency.BoundedTaskExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.ide.PooledThreadExecutor;
|
||||
|
||||
@@ -30,11 +30,11 @@ import org.jetbrains.ide.PooledThreadExecutor;
|
||||
*/
|
||||
public class MergingBackgroundExecutor<T> {
|
||||
private final Consumer<T> myConsumer;
|
||||
private final BoundedTaskExecutorService myExecutorService;
|
||||
private final BoundedTaskExecutor myExecutorService;
|
||||
|
||||
public MergingBackgroundExecutor(int maxThreads, @NotNull Consumer<T> consumer) {
|
||||
myConsumer = consumer;
|
||||
myExecutorService = new BoundedTaskExecutorService(PooledThreadExecutor.INSTANCE, maxThreads);
|
||||
myExecutorService = new BoundedTaskExecutor(PooledThreadExecutor.INSTANCE, maxThreads);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-6
@@ -31,7 +31,7 @@ public class BoundedTaskExecutorTest extends TestCase {
|
||||
for (int maxTasks=1; maxTasks<5;maxTasks++) {
|
||||
System.out.println("maxTasks = " + maxTasks);
|
||||
ExecutorService backendExecutor = Executors.newCachedThreadPool(ConcurrencyUtil.newNamedThreadFactory("maxTasks = " + maxTasks));
|
||||
BoundedTaskExecutorService executor = new BoundedTaskExecutorService(backendExecutor, maxTasks);
|
||||
BoundedTaskExecutor executor = new BoundedTaskExecutor(backendExecutor, maxTasks);
|
||||
AtomicInteger running = new AtomicInteger();
|
||||
AtomicInteger max = new AtomicInteger();
|
||||
AtomicInteger executed = new AtomicInteger();
|
||||
@@ -61,7 +61,7 @@ public class BoundedTaskExecutorTest extends TestCase {
|
||||
|
||||
public void testCallableReallyReturnsValue() throws Exception{
|
||||
ExecutorService backendExecutor = Executors.newCachedThreadPool(ConcurrencyUtil.newNamedThreadFactory(getName()));
|
||||
BoundedTaskExecutorService executor = new BoundedTaskExecutorService(backendExecutor, 1);
|
||||
BoundedTaskExecutor executor = new BoundedTaskExecutor(backendExecutor, 1);
|
||||
|
||||
Future<Integer> f1 = executor.submit(() -> 42);
|
||||
Integer result = f1.get();
|
||||
@@ -75,7 +75,7 @@ public class BoundedTaskExecutorTest extends TestCase {
|
||||
public void testEarlyCancelPreventsRunning() throws ExecutionException, InterruptedException {
|
||||
AtomicBoolean run = new AtomicBoolean();
|
||||
ExecutorService backendExecutor = Executors.newCachedThreadPool(ConcurrencyUtil.newNamedThreadFactory(getName()));
|
||||
BoundedTaskExecutorService executor = new BoundedTaskExecutorService(backendExecutor, 1);
|
||||
BoundedTaskExecutor executor = new BoundedTaskExecutor(backendExecutor, 1);
|
||||
|
||||
int delay = 500;
|
||||
Future<?> s1 = executor.submit((Runnable)() -> TimeoutUtil.sleep(delay));
|
||||
@@ -99,7 +99,7 @@ public class BoundedTaskExecutorTest extends TestCase {
|
||||
ExecutorService backendExecutor = Executors.newCachedThreadPool(ConcurrencyUtil.newNamedThreadFactory(getName()));
|
||||
for (int maxSimultaneousTasks = 1; maxSimultaneousTasks<20; maxSimultaneousTasks++) {
|
||||
final Disposable myDisposable = Disposer.newDisposable();
|
||||
BoundedTaskExecutorService executor = new BoundedTaskExecutorService(backendExecutor, maxSimultaneousTasks, myDisposable);
|
||||
BoundedTaskExecutor executor = new BoundedTaskExecutor(backendExecutor, maxSimultaneousTasks, myDisposable);
|
||||
AtomicInteger running = new AtomicInteger();
|
||||
AtomicInteger maxThreads = new AtomicInteger();
|
||||
|
||||
@@ -149,10 +149,10 @@ public class BoundedTaskExecutorTest extends TestCase {
|
||||
|
||||
public void testSequentialSubmitsMustExecuteSequentially() throws ExecutionException, InterruptedException {
|
||||
ExecutorService backendExecutor = Executors.newCachedThreadPool(ConcurrencyUtil.newNamedThreadFactory(getName()));
|
||||
BoundedTaskExecutorService executor = new BoundedTaskExecutorService(backendExecutor, 1);
|
||||
BoundedTaskExecutor executor = new BoundedTaskExecutor(backendExecutor, 1);
|
||||
int N = 100000;
|
||||
StringBuffer log = new StringBuffer(N*4);
|
||||
StringBuffer expected = new StringBuffer(N*4);
|
||||
StringBuilder expected = new StringBuilder(N * 4);
|
||||
|
||||
Future[] futures = new Future[N];
|
||||
for (int i = 0; i < N; i++) {
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.
|
||||
*/
|
||||
package com.intellij.util.concurrency;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 16-Sep-15
|
||||
*/
|
||||
public class BoundedTaskExecutorService extends BoundedTaskExecutor {
|
||||
public BoundedTaskExecutorService(@NotNull ExecutorService backendExecutor, int maxSimultaneousTasks) {
|
||||
super(backendExecutor, maxSimultaneousTasks);
|
||||
}
|
||||
public BoundedTaskExecutorService(@NotNull ExecutorService backendExecutor, int maxSimultaneousTasks, @NotNull Disposable parent) {
|
||||
super(backendExecutor, maxSimultaneousTasks, parent);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user