public LoaderThread(Source source, XMLByteStreamCompiler serializer) { this.source = source; this.serializer = serializer; this.finished = new CountDown( 1 ); }
private List<Exception> executeExchangeTask(ExchangeTask runnable) throws ExchangeException { Collection<Subscriber> allSubscribers = getSubscribers(); Iterator<Subscriber> subscriberIterator = allSubscribers.iterator(); final Sync done = new CountDown(allSubscribers.size()); final List<Exception> errors = new ArrayList<Exception>(); int count = 0; while (subscriberIterator.hasNext()) { count++; final Subscriber subscriber = subscriberIterator.next(); if (subscriber.isActive()) { // TODO: Inject? runnable.setErrors(errors); runnable.setSubscriber(subscriber); runnable.setSync(done); // Create runnable task for each subscriber. executeInPool(runnable); break; } else { done.release(); } } // end of subscriber loop // release unused barriers for (; count < allSubscribers.size(); count++) { done.release(); } // wait until all tasks are executed before returning back to user to make sure errors can be propagated back to the user. acquireIgnoringInterruption(done); return errors; }
private List<Exception> executeExchangeTask(ExchangeTask runnable) throws ExchangeException { Collection<Subscriber> allSubscribers = getSubscribers(); Iterator<Subscriber> subscriberIterator = allSubscribers.iterator(); final Sync done = new CountDown(allSubscribers.size()); final List<Exception> errors = new ArrayList<Exception>(); int count = 0; while (subscriberIterator.hasNext()) { count++; final Subscriber subscriber = subscriberIterator.next(); if (subscriber.isActive()) { // TODO: Inject? runnable.setErrors(errors); runnable.setSubscriber(subscriber); runnable.setSync(done); // Create runnable task for each subscriber. executeInPool(runnable); break; } else { done.release(); } } // end of subscriber loop // release unused barriers for (; count < allSubscribers.size(); count++) { done.release(); } // wait until all tasks are executed before returning back to user to make sure errors can be propagated back to the user. acquireIgnoringInterruption(done); return errors; }