当前位置: 首页>>代码示例>>Java>>正文


Java Subscriptions.empty方法代码示例

本文整理汇总了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;
}
 
开发者ID:SnowdogApps,项目名称:MoeSampleApp,代码行数:18,代码来源:HandlerThreadScheduler.java

示例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;
}
 
开发者ID:migeran,项目名称:rxmoe,代码行数:22,代码来源:HandlerThreadScheduler.java

示例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();
        }
    });
}
 
开发者ID:svarcheg,项目名称:rx-cron-scheduler,代码行数:26,代码来源:RxCronForwardingScheduler.java

示例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;
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:25,代码来源:ExecutorScheduler.java

示例5: schedule

import rx.subscriptions.Subscriptions; //导入方法依赖的package包/类
@Override
public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) {
    if (executeDelayedActions) {
        action.call();
    }
    return Subscriptions.empty();
}
 
开发者ID:hello,项目名称:android-buruberi,代码行数:8,代码来源:Testing.java

示例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();
  }
}
 
开发者ID:vinli,项目名称:android-net,代码行数:10,代码来源:PageAdapter.java

示例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());
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:39,代码来源:OperatorSwitchIfEmptyTest.java

示例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());
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:14,代码来源:OperatorSwitchIfEmptyTest.java

示例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;
}
 
开发者ID:OpenSilk,项目名称:SyncthingAndroid,代码行数:13,代码来源:SingleThreadScheduler.java

示例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();
}
 
开发者ID:svarcheg,项目名称:rx-cron-scheduler,代码行数:37,代码来源:RxCronForwardingScheduler.java

示例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;
}
 
开发者ID:Matthias247,项目名称:adalightserver,代码行数:13,代码来源:SingleThreadedComputationScheduler.java

示例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);
                }
            }

        });
    }
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:29,代码来源:TrampolineScheduler.java

示例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;
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:13,代码来源:CachedThreadScheduler.java

示例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;
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:13,代码来源:EventLoopsScheduler.java

示例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);
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:8,代码来源:NewThreadWorker.java


注:本文中的rx.subscriptions.Subscriptions.empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。