private void waitForAll(int key) throws InterruptedException { mLogger.verbose("Thread(%1$s): begin waitForAll", Thread.currentThread().getName()); ConcurrentLinkedQueue<Job<AaptProcess>> jobs = mOutstandingJobs.get(key); Job<AaptProcess> aaptProcessJob = jobs.poll(); while (aaptProcessJob != null) { mLogger.verbose("Thread(%1$s) : wait for {%2$s)", Thread.currentThread().getName(), aaptProcessJob.toString()); if (!aaptProcessJob.await()) { throw new RuntimeException( "Crunching " + aaptProcessJob.getJobTitle() + " failed, see logs"); } aaptProcessJob = jobs.poll(); } mLogger.verbose("Thread(%1$s): end waitForAll", Thread.currentThread().getName()); }
@Override @TaskAction public void compile() { final Job<Void> job = new Job<Void>(getName(), new Task<Void>() { @Override public void run(@NonNull Job<Void> job, @NonNull JobContext<Void> context) throws IOException { try { JackTask.this.doMinification(); } catch (ProcessException e) { throw new IOException(e); } } }); try { SimpleWorkQueue.push(job); // wait for the task completion. job.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } }
@Override @TaskAction public void proguard() throws IOException, ParseException { final Job<Void> job = new Job<Void>(getName(), new com.android.builder.tasks.Task<Void>() { @Override public void run(@NonNull Job<Void> job, @NonNull JobContext<Void> context) throws IOException { try { AndroidProGuardTask.this.doMinification(); } catch (ParseException e) { throw new IOException(e); } } }); try { SimpleWorkQueue.push(job); // wait for the task completion. job.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } }
job.await(); verbose("Thread(%1$s): job %2$s finished", threadName, job.getJobTitle());
boolean result = job.await(); verbose("Thread(%1$s): job %2$s finished, result=%3$b", threadName, job.getJobTitle(), result);