本文整理汇总了Java中rx.internal.schedulers.ScheduledAction类的典型用法代码示例。如果您正苦于以下问题:Java ScheduledAction类的具体用法?Java ScheduledAction怎么用?Java ScheduledAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScheduledAction类属于rx.internal.schedulers包,在下文中一共展示了ScheduledAction类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: schedule
import rx.internal.schedulers.ScheduledAction; //导入依赖的package包/类
public Subscription schedule(Action0 action) {
if (isUnsubscribed()) {
return Subscriptions.unsubscribed();
}
Subscription ea = new ScheduledAction(action, this.tasks);
this.tasks.add(ea);
this.queue.offer(ea);
if (this.wip.getAndIncrement() != 0) {
return ea;
}
try {
this.executor.execute(this);
return ea;
} catch (RejectedExecutionException t) {
this.tasks.remove(ea);
this.wip.decrementAndGet();
RxJavaPlugins.getInstance().getErrorHandler().handleError(t);
throw t;
}
}
示例2: schedule
import rx.internal.schedulers.ScheduledAction; //导入依赖的package包/类
@Override public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) {
if (compositeSubscription.isUnsubscribed()) {
return Subscriptions.unsubscribed();
}
action = RxAndroidPlugins.getInstance().getSchedulersHook().onSchedule(action);
final ScheduledAction scheduledAction = new ScheduledAction(action);
scheduledAction.addParent(compositeSubscription);
compositeSubscription.add(scheduledAction);
handler.postDelayed(scheduledAction, unit.toMillis(delayTime));
scheduledAction.add(Subscriptions.create(new Action0() {
@Override public void call() {
//Log.e(TAG, "HandlerScheduler has unsubscribed");
handler.removeCallbacks(scheduledAction);
}
}));
return scheduledAction;
}
示例3: schedule
import rx.internal.schedulers.ScheduledAction; //导入依赖的package包/类
@Override
public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) {
if (compositeSubscription.isUnsubscribed()) {
return Subscriptions.unsubscribed();
}
action = RxAndroidPlugins.getInstance().getSchedulersHook().onSchedule(action);
final ScheduledAction scheduledAction = new ScheduledAction(action);
scheduledAction.addParent(compositeSubscription);
compositeSubscription.add(scheduledAction);
handler.postDelayed(scheduledAction, unit.toMillis(delayTime));
scheduledAction.add(Subscriptions.create(new Action0() {
@Override
public void call() {
handler.removeCallbacks(scheduledAction);
}
}));
return scheduledAction;
}
示例4: schedule
import rx.internal.schedulers.ScheduledAction; //导入依赖的package包/类
@Override
public Subscription schedule(final Action0 action, long delayTime, TimeUnit unit) {
final ScheduledAction scheduledAction = new ScheduledAction(action);
scheduledAction.add(Subscriptions.create(new Action0() {
@Override
public void call() {
handler.removeCallbacks(scheduledAction);
}
}));
scheduledAction.addParent(compositeSubscription);
compositeSubscription.add(scheduledAction);
handler.postDelayed(scheduledAction, unit.toMillis(delayTime));
return scheduledAction;
}
示例5: schedule
import rx.internal.schedulers.ScheduledAction; //导入依赖的package包/类
@Override
public Subscription schedule(Action0 action, long delayTime, TimeUnit timeUnit) {
final ScheduledAction scheduledAction = new ScheduledAction(action);
scheduledAction.addParent(compositeSubscription);
compositeSubscription.add(scheduledAction);
final int taskId = BukkitRxScheduler.scheduleOnBukkitScheduler(plugin, scheduledAction, timeUnitToBukkitTicks(delayTime, timeUnit), concurrencyMode);
scheduledAction.add(Subscriptions.create(new Action0() {
@Override
public void call() {
plugin.getServer().getScheduler().cancelTask(taskId);
}
}));
return scheduledAction;
}
示例6: run
import rx.internal.schedulers.ScheduledAction; //导入依赖的package包/类
public void run() {
do {
ScheduledAction sa = (ScheduledAction) this.queue.poll();
if (!sa.isUnsubscribed()) {
sa.run();
}
} while (this.wip.decrementAndGet() > 0);
}
示例7: schedule
import rx.internal.schedulers.ScheduledAction; //导入依赖的package包/类
public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) {
if (this.compositeSubscription.isUnsubscribed()) {
return Subscriptions.unsubscribed();
}
final Subscription scheduledAction = new ScheduledAction(RxAndroidPlugins.getInstance().getSchedulersHook().onSchedule(action));
scheduledAction.addParent(this.compositeSubscription);
this.compositeSubscription.add(scheduledAction);
this.handler.postDelayed(scheduledAction, unit.toMillis(delayTime));
scheduledAction.add(Subscriptions.create(new Action0() {
public void call() {
HandlerWorker.this.handler.removeCallbacks(scheduledAction);
}
}));
return scheduledAction;
}
示例8: testNoSelfInterrupt
import rx.internal.schedulers.ScheduledAction; //导入依赖的package包/类
@Test(timeout = 3000)
public void testNoSelfInterrupt() throws InterruptedException {
Scheduler.Worker worker = Schedulers.newThread().createWorker();
try {
final CountDownLatch run = new CountDownLatch(1);
final CountDownLatch done = new CountDownLatch(1);
final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
final AtomicBoolean interruptFlag = new AtomicBoolean();
ScheduledAction sa = (ScheduledAction)worker.schedule(new Action0() {
@Override
public void call() {
try {
run.await();
} catch (InterruptedException ex) {
exception.set(ex);
}
}
});
sa.add(Subscriptions.create(new Action0() {
@Override
public void call() {
interruptFlag.set(Thread.currentThread().isInterrupted());
done.countDown();
}
}));
run.countDown();
done.await();
Assert.assertEquals(null, exception.get());
Assert.assertFalse("Interrupted?!", interruptFlag.get());
} finally {
worker.unsubscribe();
}
}
示例9: schedule
import rx.internal.schedulers.ScheduledAction; //导入依赖的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: schedule
import rx.internal.schedulers.ScheduledAction; //导入依赖的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;
}
示例11: schedule
import rx.internal.schedulers.ScheduledAction; //导入依赖的package包/类
@Override
public Subscription schedule(Action0 action) {
if (isUnsubscribed()) {
return Subscriptions.unsubscribed();
}
ScheduledAction s = poolWorker.scheduleActual(action, 0, null, serial);
return s;
}
示例12: schedule
import rx.internal.schedulers.ScheduledAction; //导入依赖的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;
}
示例13: schedule
import rx.internal.schedulers.ScheduledAction; //导入依赖的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;
}