本文整理汇总了Java中rx.subscriptions.Subscriptions.empty方法的典型用法代码示例。如果您正苦于以下问题:Java Subscriptions.empty方法的具体用法?Java Subscriptions.empty怎么用?Java Subscriptions.empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.subscriptions.Subscriptions
的用法示例。
在下文中一共展示了Subscriptions.empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: schedule
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription schedule(final Action0 action, long delayTime, TimeUnit unit) {
if (innerSubscription.isUnsubscribed()) {
return Subscriptions.empty();
}
final ScheduledAction scheduledAction = new ScheduledAction(action, operationQueue);
final ScheduledExecutorService executor = IOSScheduledExecutorPool.getInstance();
Future<?> future;
if (delayTime <= 0) {
future = executor.submit(scheduledAction);
} else {
future = executor.schedule(scheduledAction, delayTime, unit);
}
scheduledAction.add(Subscriptions.from(future));
scheduledAction.addParent(innerSubscription);
return scheduledAction;
}
示例2: schedule
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription schedule(final Action0 action, long delayTime, TimeUnit unit) {
if (innerSubscription.isUnsubscribed()) {
return Subscriptions.empty();
}
final ScheduledAction scheduledAction = new ScheduledAction(action, operationQueue);
final ScheduledExecutorService executor = IOSScheduledExecutorPool.getInstance();
Future<?> future;
if (delayTime <= 0) {
future = executor.submit(scheduledAction);
} else {
future = executor.schedule(scheduledAction, delayTime, unit);
}
scheduledAction.add(Subscriptions.from(future));
scheduledAction.addParent(innerSubscription);
return scheduledAction;
}
示例3: schedule
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public <T> Subscription schedule(T state, final Func2<? super Scheduler, ? super T, ? extends Subscription> action, final CronExpression cronExpression, final Calendar calendar)
{
final AtomicBoolean complete = new AtomicBoolean();
Date initialfireTime = findNextExecutionTime(new Date(now()), cronExpression, calendar);
RecursiveAction<T> recursiveAction = new RecursiveAction<T>(complete, action, cronExpression, calendar, initialfireTime);
final Subscription sub;
if (initialfireTime == null)
{
sub = Subscriptions.empty();
}
else
{
sub = schedule(state, recursiveAction, initialfireTime);
}
return Subscriptions.create(new Action0()
{
@Override
public void call()
{
complete.set(true);
sub.unsubscribe();
}
});
}
示例4: schedule
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription schedule(Action0 action) {
if (isUnsubscribed()) {
return Subscriptions.empty();
}
ExecutorAction ea = new ExecutorAction(action, tasks);
tasks.add(ea);
queue.offer(ea);
if (wip.getAndIncrement() == 0) {
try {
executor.execute(this);
} catch (RejectedExecutionException t) {
// cleanup if rejected
tasks.remove(ea);
wip.decrementAndGet();
// report the error to the plugin
RxJavaPlugins.getInstance().getErrorHandler().handleError(t);
// throw it to the caller
throw t;
}
}
return ea;
}
示例5: schedule
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) {
if (executeDelayedActions) {
action.call();
}
return Subscriptions.empty();
}
示例6: loadNext
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
/** Use {@link #loadNext()} instead. */
@Deprecated
public Subscription loadNext(Object context) {
if (hasNext()) {
return bind(pages.get(pages.size() - 1).loadNextPage()).subscribe(subscriber);
} else {
return Subscriptions.empty();
}
}
示例7: testSwitchTriggerUnsubscribe
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Test
public void testSwitchTriggerUnsubscribe() throws Exception {
final Subscription empty = Subscriptions.empty();
Observable<Long> withProducer = Observable.create(new Observable.OnSubscribe<Long>() {
@Override
public void call(final Subscriber<? super Long> subscriber) {
subscriber.add(empty);
subscriber.onNext(42L);
}
});
final Subscription sub = Observable.<Long>empty().switchIfEmpty(withProducer).lift(new Observable.Operator<Long, Long>() {
@Override
public Subscriber<? super Long> call(final Subscriber<? super Long> child) {
return new Subscriber<Long>(child) {
@Override
public void onComplete() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(Long aLong) {
unsubscribe();
}
};
}
}).subscribe();
assertTrue(empty.isUnsubscribed());
assertTrue(sub.isUnsubscribed());
}
示例8: testSwitchShouldTriggerUnsubscribe
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Test
public void testSwitchShouldTriggerUnsubscribe() {
final Subscription s = Subscriptions.empty();
Observable.create(new Observable.OnSubscribe<Long>() {
@Override
public void call(final Subscriber<? super Long> subscriber) {
subscriber.add(s);
subscriber.onComplete();
}
}).switchIfEmpty(Observable.<Long>never()).subscribe();
assertTrue(s.isUnsubscribed());
}
示例9: schedule
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) {
if (innerSubscription.isUnsubscribed()) {
// don't schedule, we are unsubscribed
return Subscriptions.empty();
}
ScheduledAction s = worker.scheduleActual(action, delayTime, unit);
innerSubscription.add(s);
s.addParent(innerSubscription);
return s;
}
示例10: call
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription call(Scheduler scheduler, T state0)
{
if (!complete.get())
{
final Subscription sub1;
if (scheduler.now() < dueTime.getTime())
{
sub1 = Subscriptions.empty();
}
else
{
sub1 = action.call(scheduler, state0);
}
Date fireTime = findNextExecutionTime(new Date(scheduler.now()), cronExpression, calendar);
final Subscription sub2;
if (fireTime == null)
{
sub2 = Subscriptions.empty();
}
else
{
sub2 = scheduler.schedule(state0, new RecursiveAction<T>(complete, action, cronExpression, calendar, fireTime), fireTime);
}
return Subscriptions.create(new Action0()
{
@Override
public void call()
{
sub1.unsubscribe();
sub2.unsubscribe();
}
});
}
return Subscriptions.empty();
}
示例11: schedule
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) {
if (innerSubscription.isUnsubscribed()) {
// don't schedule, we are unsubscribed
return Subscriptions.empty();
}
ScheduledAction s = (ScheduledAction)innerWorker.schedule(action, delayTime, unit);
innerSubscription.add(s);
s.addParent(innerSubscription);
return s;
}
示例12: enqueue
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
private Subscription enqueue(Action0 action, long execTime) {
if (innerSubscription.isUnsubscribed()) {
return Subscriptions.empty();
}
PriorityQueue<TimedAction> queue = QUEUE.get();
final TimedAction timedAction = new TimedAction(action, execTime, COUNTER_UPDATER.incrementAndGet(TrampolineScheduler.this));
queue.add(timedAction);
if (wip.getAndIncrement() == 0) {
do {
queue.poll().action.call();
} while (wip.decrementAndGet() > 0);
return Subscriptions.empty();
} else {
// queue wasn't empty, a parent is already processing so we just add to the end of the queue
return Subscriptions.create(new Action0() {
@Override
public void call() {
PriorityQueue<TimedAction> _q = QUEUE.get();
if (_q != null) {
_q.remove(timedAction);
}
}
});
}
}
示例13: schedule
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) {
if (innerSubscription.isUnsubscribed()) {
// don't schedule, we are unsubscribed
return Subscriptions.empty();
}
ScheduledAction s = threadWorker.scheduleActual(action, delayTime, unit);
innerSubscription.add(s);
s.addParent(innerSubscription);
return s;
}
示例14: schedule
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) {
if (innerSubscription.isUnsubscribed()) {
// don't schedule, we are unsubscribed
return Subscriptions.empty();
}
ScheduledAction s = poolWorker.scheduleActual(action, delayTime, unit);
innerSubscription.add(s);
s.addParent(innerSubscription);
return s;
}
示例15: schedule
import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription schedule(final Action0 action, long delayTime, TimeUnit unit) {
if (isUnsubscribed) {
return Subscriptions.empty();
}
return scheduleActual(action, delayTime, unit);
}