@Override protected void beginning() { lastTime.set(System.nanoTime()); promiseFactory.scheduledExecutor().schedule( () -> check(lastTime, timeout), timeout, NANOSECONDS); } };
@Override protected void beginning() { lastTime.set(System.nanoTime()); promiseFactory.scheduledExecutor().schedule( () -> check(lastTime, timeout), timeout, NANOSECONDS); } };
@Override protected void beginning() { lastTime.set(System.nanoTime()); promiseFactory.scheduledExecutor().schedule( () -> check(lastTime, timeout), timeout, NANOSECONDS); } };
/** * Schedule a operation on the scheduled executor. * * @since 1.1 */ ScheduledFuture< ? > schedule(Runnable operation, long delay, TimeUnit unit) { try { try { return factory.scheduledExecutor().schedule(operation, delay, unit); } catch (RejectedExecutionException e) { operation.run(); } } catch (Throwable t) { uncaughtException(t); } return null; }
/** * Schedule a operation on the scheduled executor. * * @since 1.1 */ ScheduledFuture< ? > schedule(Runnable operation, long delay, TimeUnit unit) { try { try { return factory.scheduledExecutor().schedule(operation, delay, unit); } catch (RejectedExecutionException e) { operation.run(); } } catch (Throwable t) { uncaughtException(t); } return null; }
/** * Schedule a operation on the scheduled executor. * * @since 1.1 */ ScheduledFuture< ? > schedule(Runnable operation, long delay, TimeUnit unit) { try { try { return factory.scheduledExecutor().schedule(operation, delay, unit); } catch (RejectedExecutionException e) { operation.run(); } } catch (Throwable t) { uncaughtException(t); } return null; }
/** * Schedule a operation on the scheduled executor. * * @since 1.1 */ ScheduledFuture< ? > schedule(Runnable operation, long delay, TimeUnit unit) { try { try { return factory.scheduledExecutor().schedule(operation, delay, unit); } catch (RejectedExecutionException e) { operation.run(); } } catch (Throwable t) { uncaughtException(t); } return null; }
/** * Schedule a operation on the scheduled executor. * * @since 1.1 */ ScheduledFuture< ? > schedule(Runnable operation, long delay, TimeUnit unit) { try { try { return factory.scheduledExecutor().schedule(operation, delay, unit); } catch (RejectedExecutionException e) { operation.run(); } } catch (Throwable t) { uncaughtException(t); } return null; }
/** * Schedule a operation on the scheduled executor. * * @since 1.1 */ ScheduledFuture< ? > schedule(Runnable operation, long delay, TimeUnit unit) { try { try { return factory.scheduledExecutor().schedule(operation, delay, unit); } catch (RejectedExecutionException e) { operation.run(); } } catch (Throwable t) { uncaughtException(t); } return null; }
/** * Schedule a operation on the scheduled executor. * * @since 1.1 */ ScheduledFuture< ? > schedule(Runnable operation, long delay, TimeUnit unit) { try { try { return factory.scheduledExecutor().schedule(operation, delay, unit); } catch (RejectedExecutionException e) { operation.run(); } } catch (Throwable t) { uncaughtException(t); } return null; }
public SimplePushEventSourceImpl(PromiseFactory promiseFactory, QueuePolicy<T,U> queuePolicy, U queue, int parallelism, Runnable onClose) { this.promiseFactory = promiseFactory; this.sameThread = new PromiseFactory( PromiseFactory.inlineExecutor(), promiseFactory.scheduledExecutor()); this.queuePolicy = queuePolicy; this.queue = queue; this.parallelism = parallelism; this.semaphore = new Semaphore(parallelism); this.onClose = onClose; this.closed = false; this.connectPromise = null; }
public SimplePushEventSourceImpl(PromiseFactory promiseFactory, QueuePolicy<T,U> queuePolicy, U queue, int parallelism, Runnable onClose) { this.promiseFactory = promiseFactory; this.sameThread = new PromiseFactory( PromiseFactory.inlineExecutor(), promiseFactory.scheduledExecutor()); this.queuePolicy = queuePolicy; this.queue = queue; this.parallelism = parallelism; this.semaphore = new Semaphore(parallelism); this.onClose = onClose; this.closed = false; this.connectPromise = null; }
public SimplePushEventSourceImpl(PromiseFactory promiseFactory, QueuePolicy<T,U> queuePolicy, U queue, int parallelism, Runnable onClose) { this.promiseFactory = promiseFactory; this.sameThread = new PromiseFactory( PromiseFactory.inlineExecutor(), promiseFactory.scheduledExecutor()); this.queuePolicy = queuePolicy; this.queue = queue; this.parallelism = parallelism; this.semaphore = new Semaphore(parallelism); this.onClose = onClose; this.closed = false; this.connectPromise = null; }
void check(AtomicLong lastTime, long timeout) { long now = System.nanoTime(); long elapsed = now - lastTime.get(); if (elapsed < timeout) { promiseFactory.scheduledExecutor().schedule( () -> check(lastTime, timeout), timeout - elapsed, NANOSECONDS); } else { PushEvent<T> error = PushEvent.error(new TimeoutException()); close(error); // Upstream close is needed as we have no direct backpressure upstreamClose(error); } }
void check(AtomicLong lastTime, long timeout) { long now = System.nanoTime(); long elapsed = now - lastTime.get(); if (elapsed < timeout) { promiseFactory.scheduledExecutor().schedule( () -> check(lastTime, timeout), timeout - elapsed, NANOSECONDS); } else { PushEvent<T> error = PushEvent.error(new TimeoutException()); close(error); // Upstream close is needed as we have no direct backpressure upstreamClose(error); } }
void check(AtomicLong lastTime, long timeout) { long now = System.nanoTime(); long elapsed = now - lastTime.get(); if (elapsed < timeout) { promiseFactory.scheduledExecutor().schedule( () -> check(lastTime, timeout), timeout - elapsed, NANOSECONDS); } else { PushEvent<T> error = PushEvent.error(new TimeoutException()); close(error); // Upstream close is needed as we have no direct backpressure upstreamClose(error); } }
@Override public PushStream<T> limit(Duration maxTime) { Runnable start = () -> promiseFactory.scheduledExecutor().schedule( () -> close(), maxTime.toNanos(), NANOSECONDS); AbstractPushStreamImpl<T> eventStream = new IntermediatePushStreamImpl<T>( psp, promiseFactory, this) { @Override protected void beginning() { start.run(); } }; updateNext((event) -> { try { return eventStream.handleEvent(event); } catch (Exception e) { close(PushEvent.error(e)); return ABORT; } }); return eventStream; }
private void pushData(Iterator<T> it) { while (it.hasNext()) { try { long returnValue = closed.get() == CLOSED ? -1 : handleEvent(data(it.next())); if (returnValue != 0) { if (returnValue < 0) { close(); return; } else { promiseFactory.scheduledExecutor() .schedule( () -> promiseFactory.executor() .execute(() -> pushData(it)), returnValue, MILLISECONDS); return; } } } catch (Exception e) { close(error(e)); } } close(); } };
@Override public PushStream<T> limit(Duration maxTime) { Runnable start = () -> promiseFactory.scheduledExecutor().schedule( () -> close(), maxTime.toNanos(), NANOSECONDS); AbstractPushStreamImpl<T> eventStream = new IntermediatePushStreamImpl<T>( psp, promiseFactory, this) { @Override protected void beginning() { start.run(); } }; updateNext((event) -> { try { return eventStream.handleEvent(event); } catch (Exception e) { close(PushEvent.error(e)); return ABORT; } }); return eventStream; }
private void pushData(Iterator<T> it) { while (it.hasNext()) { try { long returnValue = closed.get() == CLOSED ? -1 : handleEvent(data(it.next())); if (returnValue != 0) { if (returnValue < 0) { close(); return; } else { promiseFactory.scheduledExecutor() .schedule( () -> promiseFactory.executor() .execute(() -> pushData(it)), returnValue, MILLISECONDS); return; } } } catch (Exception e) { close(error(e)); } } close(); } };