PeriodicTask(long firstStartInNanoseconds, @NonNull Runnable decoratedRun, long firstNowNanoseconds, @NonNull SequentialDisposable sd, long periodInNanoseconds) { this.decoratedRun = decoratedRun; this.sd = sd; this.periodInNanoseconds = periodInNanoseconds; lastNowNanoseconds = firstNowNanoseconds; startInNanoseconds = firstStartInNanoseconds; }
/** * Apply some calculation to the input value and return some other value. * @param t the input value * @return the output value * @throws Exception on error */ R apply(@NonNull T t) throws Exception; }
@Override @NonNull public String getMessage() { return message; }
/** * Returns the time unit of the contained time. * @return the time unit of the contained time */ @NonNull public TimeUnit unit() { return unit; }
/** * Wraps the {@code Throwable} before it * is signalled to the {@code RxJavaCommonPlugins.onError()} * handler as {@code OnErrorNotImplementedException}. * * @param e * the {@code Throwable} to signal; if null, a NullPointerException is constructed */ public OnErrorNotImplementedException(@NonNull Throwable e) { super(e != null ? e.getMessage() : null, e != null ? e : new NullPointerException()); } }
@NonNull @Override public Disposable schedule(@NonNull final Runnable action, final long delayTime, @NonNull final TimeUnit unit) { // send a scheduled action to the actionQueue DelayedAction delayedAction = new DelayedAction(action, delayTime, unit); actionProcessor.onNext(delayedAction); return delayedAction; }
/** * Wraps the call to the Scheduler creation function in try-catch and propagates thrown * checked exceptions as RuntimeException and enforces that result is not null. * @param f the function to call, not null (not verified). Cannot return null * @param s the parameter value to the function * @return the result of the function call, not null * @throws NullPointerException if the function parameter returns null */ @NonNull static Scheduler applyRequireNonNull(@NonNull Function<? super Callable<Scheduler>, ? extends Scheduler> f, Callable<Scheduler> s) { return ObjectHelper.requireNonNull(apply(f, s), "Scheduler Callable result can't be null"); }
@NonNull @Override public Worker createWorker() { return new ScheduledWorker(executor.get()); }
@NonNull @Override public Disposable schedule(@NonNull Runnable run, long delayTime, @NonNull TimeUnit unit) { if (disposed) { return REJECTED; } final TimedRunnable timedAction = new TimedRunnable(this, time + unit.toNanos(delayTime), run, counter++); queue.add(timedAction); return Disposables.fromRunnable(new QueueRemove(timedAction)); }
/** * Returns an {@code Observable} that stays connected to this {@code ConnectableObservable} as long as there * is at least one subscription to this {@code ConnectableObservable}. * * @return a {@link Flowable} * @see <a href="http://reactivex.io/documentation/operators/refcount.html">ReactiveX documentation: RefCount</a> */ @NonNull public Flowable<T> refCount() { return RxJavaFlowablePlugins.onAssembly(new FlowableRefCount<T>(this)); }
/** * Creates a new AsyncProcessor. * @param <T> the value type to be received and emitted * @return the new AsyncProcessor instance */ @CheckReturnValue @NonNull public static <T> AsyncProcessor<T> create() { return new AsyncProcessor<T>(); }
@NonNull @Override public Disposable schedule(@NonNull final Runnable action, final long delayTime, @NonNull final TimeUnit delayUnit) { TimeUnit common = delayUnit.compareTo(unit) < 0 ? delayUnit : unit; long t = common.convert(delayTime, delayUnit) + common.convert(delay, unit); return actualInner.schedule(action, t, common); }
/** * Filters the source values on each 'rail'. * <p> * Note that the same predicate may be called from multiple threads concurrently. * @param predicate the function returning true to keep a value or false to drop a value * @return the new ParallelFlowable instance */ @CheckReturnValue public final ParallelFlowable<T> filter(@NonNull Predicate<? super T> predicate) { ObjectHelper.requireNonNull(predicate, "predicate"); return RxJavaFlowablePlugins.onAssembly(new ParallelFilter<T>(this, predicate)); }
@NonNull @Override public Worker createWorker() { return new SlowInner(actual.createWorker()); }