API for invoking runnable on as many cores as possible
authorAlexey Kudravtsev <cdr@intellij.com>
Mon, 7 Jun 2010 13:06:36 +0000 (17:06 +0400)
committerAlexey Kudravtsev <cdr@intellij.com>
Wed, 9 Jun 2010 09:12:41 +0000 (13:12 +0400)
platform/platform-impl/src/com/intellij/concurrency/JobUtil.java

index c5f68591b4c495e59bfb761578cef3e9a01654ec..8f99cb76b59f56afaf6b6f698e596702ded2b526 100644 (file)
@@ -114,6 +114,14 @@ public class JobUtil {
     }, failFastOnAcquireReadAction);
   }
 
+  public static void invokeConcurrentlyOnAllCores(@NotNull final Runnable action) throws Throwable {
+    Job<Void> job = new JobImpl<Void>(Job.DEFAULT_PRIORITY, false);
+    for (int i=0; i< JobSchedulerImpl.CORES_COUNT; i++) {
+      job.addTask(action);
+    }
+    job.scheduleAndWaitForResults();
+  }
+
   public static Job<Void> submitToJobThread(@NotNull final Runnable action, int priority) {
     Job<Void> job = new JobImpl<Void>(priority, false);
     Callable<Void> callable = new Callable<Void>() {