@Override public void process(final A a) { while (!canAdd()) { waitForInput(); if (blocking) processOutput(); } if (stopped) { input.clear(); counter.set(0); return; } add(a); service.submit(this); }
@Override public void run() { doInAsyncTask(); } }
@Override protected void onEnd() { endTask(); } }).execute();
@Override protected void onEnd() { if (!blocking || stopped) return; while (!isEnded()) { waitForOutput(); processOutput(); } processOutput(); super.onEnd(); }
public void doInAsyncTask() { try { Flow<B> flow = mapper.map(take()); flow.then(new FlowProcessor<B, B>() { @Override public void process(B b) { try { if (blocking) output.put(b); notifyIfWaiting(); } catch (InterruptedException e) { throw Unchecked.rethrow(e); } } @Override protected void onEnd() { endTask(); } }).execute(); } catch (Exception ex) { endTask(); throw Unchecked.rethrow(ex); } }
protected void endTask() { counter.decrementAndGet(); notifyIfWaiting(); }
public <T> Flow<T> async(ExecutorService service, int queueLimit, Mapper<B, Flow<T>> mapper) { return then(new FlowAsync<B, T>(service, queueLimit, mapper)); }
@Override protected void onEnd() { if (!blocking || stopped) return; while (!isEnded()) { waitForOutput(); processOutput(); } processOutput(); super.onEnd(); }
public void doInAsyncTask() { try { Flow<B> flow = mapper.map(take()); flow.then(new FlowProcessor<B, B>() { @Override public void process(B b) { try { if (blocking) output.put(b); notifyIfWaiting(); } catch (InterruptedException e) { throw Unchecked.rethrow(e); } } @Override protected void onEnd() { endTask(); } }).execute(); } catch (Exception ex) { endTask(); throw Unchecked.rethrow(ex); } }
protected void endTask() { counter.decrementAndGet(); notifyIfWaiting(); }
public <T> Flow<T> async(Mapper<B, Flow<T>> mapper) { return then(new FlowAsync<B, T>(mapper)); }
@Override public void process(final A a) { while (!canAdd()) { waitForInput(); if (blocking) processOutput(); } if (stopped) { input.clear(); counter.set(0); return; } add(a); service.submit(this); }
protected A take() { try { return input.take(); } catch (InterruptedException e) { throw Unchecked.rethrow(e); } finally { notifyIfWaiting(); } }
public <T> Flow<T> async(int queueLimit, Mapper<B, Flow<T>> mapper) { return then(new FlowAsync<B, T>(queueLimit, mapper)); }
@Override protected void onEnd() { endTask(); } }).execute();
@Override public void run() { doInAsyncTask(); } }
protected A take() { try { return input.take(); } catch (InterruptedException e) { throw Unchecked.rethrow(e); } finally { notifyIfWaiting(); } }
public <T> Flow<T> async(Mapper<B, Flow<T>> mapper) { return then(new FlowAsync<B, T>(mapper)); }
@Override public void process(B b) { try { if (blocking) output.put(b); notifyIfWaiting(); } catch (InterruptedException e) { throw Unchecked.rethrow(e); } }
public <T> Flow<T> async(int queueLimit, Mapper<B, Flow<T>> mapper) { return then(new FlowAsync<B, T>(queueLimit, mapper)); }