diff --git a/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java b/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java index 2ef9cfbedc61..cdc892071e01 100644 --- a/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java +++ b/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -46,8 +46,9 @@ public class BoundedTaskExecutor implements Executor { } }; - public BoundedTaskExecutor(Executor backendExecutor, int maxSimultaneousTasks) { + public BoundedTaskExecutor(@NotNull Executor backendExecutor, int maxSimultaneousTasks) { myBackendExecutor = backendExecutor; + assert maxSimultaneousTasks >= 1 : maxSimultaneousTasks; myMaxTasks = Math.max(maxSimultaneousTasks, 1); } @@ -56,7 +57,8 @@ public class BoundedTaskExecutor implements Executor { submit(task); } - public Future submit(Runnable task) { + @NotNull + public Future submit(@NotNull Runnable task) { final RunnableFuture future = queueTask(new FutureTask(task, null)); if (future == null) { throw new RuntimeException("Failed to queue task: " + task); @@ -64,7 +66,8 @@ public class BoundedTaskExecutor implements Executor { return future; } - public Future submit(Callable task) { + @NotNull + public Future submit(@NotNull Callable task) { final RunnableFuture future = queueTask(new FutureTask(task)); if (future == null) { throw new RuntimeException("Failed to queue task: " + task); @@ -73,7 +76,7 @@ public class BoundedTaskExecutor implements Executor { } @Nullable - private RunnableFuture queueTask(FutureTask futureTask) { + private RunnableFuture queueTask(@NotNull FutureTask futureTask) { if (myTaskQueue.offer(futureTask)) { processQueue(); return futureTask; diff --git a/platform/util/src/com/intellij/util/concurrency/SequentialTaskExecutor.java b/platform/util/src/com/intellij/util/concurrency/SequentialTaskExecutor.java index c05579c8f002..86fa72075e90 100644 --- a/platform/util/src/com/intellij/util/concurrency/SequentialTaskExecutor.java +++ b/platform/util/src/com/intellij/util/concurrency/SequentialTaskExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -16,11 +16,12 @@ package com.intellij.util.concurrency; +import org.jetbrains.annotations.NotNull; + import java.util.concurrent.Executor; public class SequentialTaskExecutor extends BoundedTaskExecutor { - - public SequentialTaskExecutor(Executor executor) { + public SequentialTaskExecutor(@NotNull Executor executor) { super(executor, 1); } }