diff --git a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java index a20e1d29b889..125b39bad4a4 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java +++ b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java @@ -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 documentsToCommit = new Queue(10); private final List documentsToApplyInEDT = new ArrayList(10); // guarded by documentsToCommit diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java index b0d975512276..3a3abb35a857 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java @@ -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 filesToRedetect = new LinkedBlockingDeque(); private void awakeReDetectExecutor() { diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java index f3b3af9d2fa4..eed6a0a95332 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java @@ -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 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() { diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshQueueImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshQueueImpl.java index 9f02411c3383..3e93027c4675 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshQueueImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshQueueImpl.java @@ -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 mySessions = new TLongObjectHashMap(); private final FrequentEventDetector myEventCounter = new FrequentEventDetector(100, 100, FrequentEventDetector.Level.ERROR); diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java index d79e77ee2a32..0ca16690bc3a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java @@ -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; diff --git a/platform/platform-impl/src/com/intellij/util/MergingBackgroundExecutor.java b/platform/platform-impl/src/com/intellij/util/MergingBackgroundExecutor.java index 8a9bbfabecd6..e8ef29cbebe4 100644 --- a/platform/platform-impl/src/com/intellij/util/MergingBackgroundExecutor.java +++ b/platform/platform-impl/src/com/intellij/util/MergingBackgroundExecutor.java @@ -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 { private final Consumer myConsumer; - private final BoundedTaskExecutorService myExecutorService; + private final BoundedTaskExecutor myExecutorService; public MergingBackgroundExecutor(int maxThreads, @NotNull Consumer consumer) { myConsumer = consumer; - myExecutorService = new BoundedTaskExecutorService(PooledThreadExecutor.INSTANCE, maxThreads); + myExecutorService = new BoundedTaskExecutor(PooledThreadExecutor.INSTANCE, maxThreads); } diff --git a/platform/platform-tests/testSrc/com/intellij/util/concurrency/BoundedTaskExecutorTest.java b/platform/platform-tests/testSrc/com/intellij/util/concurrency/BoundedTaskExecutorTest.java index 2fc5deb62ef9..38275a819c86 100644 --- a/platform/platform-tests/testSrc/com/intellij/util/concurrency/BoundedTaskExecutorTest.java +++ b/platform/platform-tests/testSrc/com/intellij/util/concurrency/BoundedTaskExecutorTest.java @@ -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 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++) { diff --git a/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutorService.java b/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutorService.java deleted file mode 100644 index 861cdaa83580..000000000000 --- a/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutorService.java +++ /dev/null @@ -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); - } -}