diff options
author | Tor Norbye <tnorbye@google.com> | 2014-09-04 13:25:33 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-09-04 13:25:33 -0700 |
commit | d245f58efbfc26b13b9b9d5e52e6a83a0d76216c (patch) | |
tree | bca7d49005d81d10c70bc3f547df041c636b4300 /platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java | |
parent | 9cde0e3c015174898df8b8f3672185941fad4786 (diff) | |
parent | c3d3a90f6b4ead083d63e28e6b9fcea93d675678 (diff) | |
download | idea-d245f58efbfc26b13b9b9d5e52e6a83a0d76216c.tar.gz |
Merge remote-tracking branch 'aosp/upstream-master' into merge
Diffstat (limited to 'platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java')
-rw-r--r-- | platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java | 13 |
1 files changed, 8 insertions, 5 deletions
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<Void> future = queueTask(new FutureTask<Void>(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 <T> Future<T> submit(Callable<T> task) { + @NotNull + public <T> Future<T> submit(@NotNull Callable<T> task) { final RunnableFuture<T> future = queueTask(new FutureTask<T>(task)); if (future == null) { throw new RuntimeException("Failed to queue task: " + task); @@ -73,7 +76,7 @@ public class BoundedTaskExecutor implements Executor { } @Nullable - private <T> RunnableFuture<T> queueTask(FutureTask<T> futureTask) { + private <T> RunnableFuture<T> queueTask(@NotNull FutureTask<T> futureTask) { if (myTaskQueue.offer(futureTask)) { processQueue(); return futureTask; |