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


Java Worker.schedule方法代码示例

本文整理汇总了Java中rx.Scheduler.Worker.schedule方法的典型用法代码示例。如果您正苦于以下问题:Java Worker.schedule方法的具体用法?Java Worker.schedule怎么用?Java Worker.schedule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rx.Scheduler.Worker的用法示例。


在下文中一共展示了Worker.schedule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doWorkOnNewTrampoline

import rx.Scheduler.Worker; //导入方法依赖的package包/类
private static Worker doWorkOnNewTrampoline(final String key, final ArrayList<String> workDone) {
    Worker worker = Schedulers.trampoline().createWorker();
    worker.schedule(new Action0() {

        @Override
        public void call() {
            String msg = key + ".1";
            workDone.add(msg);
            System.out.println(msg);
            Worker worker3 = Schedulers.trampoline().createWorker();
            worker3.schedule(createPrintAction(key + ".B.1", workDone));
            worker3.schedule(createPrintAction(key + ".B.2", workDone));
        }

    });
    return worker;
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:18,代码来源:TrampolineSchedulerTest.java

示例2: blockUntilWorkFinished

import rx.Scheduler.Worker; //导入方法依赖的package包/类
public static void blockUntilWorkFinished(Scheduler scheduler, int numThreads, long timeout,
        TimeUnit unit) {
    final CountDownLatch latch = new CountDownLatch(numThreads);
    for (int i = 1; i <= numThreads; i++) {
        final Worker worker = scheduler.createWorker();
        worker.schedule(new Action0() {

            @Override
            public void call() {
                worker.unsubscribe();
                latch.countDown();
            }
        });
    }
    try {
        boolean finished = latch.await(timeout, unit);
        if (!finished) {
            throw new RuntimeException("timeout occured waiting for work to finish");
        }
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:davidmoten,项目名称:rxjava-extras,代码行数:24,代码来源:Schedulers.java

示例3: call

import rx.Scheduler.Worker; //导入方法依赖的package包/类
@Override
public Subscriber<? super T> call(Subscriber<? super T> child) {
    Subscriber<T> parent;
    if (firstTime.compareAndSet(true, false)) {
        // don't delay subscription for the first time
        parent = Subscribers.from(child);
    } else {
        final PublishSubject<T> subject = PublishSubject.create();
        Worker worker = scheduler.createWorker();
        worker.schedule(() -> {
            subject.unsafeSubscribe(child);
        }, duration, units);
        child.add(worker);
        parent = Subscribers.from(subject);
    }
    child.add(parent);
    return parent;
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:19,代码来源:OperatorSubscriptionInterval.java

示例4: call

import rx.Scheduler.Worker; //导入方法依赖的package包/类
@Override
public void call(final Subscriber<? super Long> child) {
    Worker worker = scheduler.createWorker();
    child.add(worker);
    worker.schedule(new Action0() {
        @Override
        public void call() {
            try {
                child.onNext(0L);
            } catch (Throwable t) {
                child.onError(t);
                return;
            }
            child.onCompleted();
        }
    }, time, unit);
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:18,代码来源:OnSubscribeTimerOnce.java

示例5: call

import rx.Scheduler.Worker; //导入方法依赖的package包/类
public Subscriber<? super T> call(final Subscriber<? super T> child) {
    Worker worker = this.scheduler.createWorker();
    child.add(worker);
    final AtomicBoolean gate = new AtomicBoolean();
    worker.schedule(new Action0() {
        public void call() {
            gate.set(true);
        }
    }, this.time, this.unit);
    return new Subscriber<T>(child) {
        public void onNext(T t) {
            if (gate.get()) {
                child.onNext(t);
            }
        }

        public void onError(Throwable e) {
            try {
                child.onError(e);
            } finally {
                unsubscribe();
            }
        }

        public void onCompleted() {
            try {
                child.onCompleted();
            } finally {
                unsubscribe();
            }
        }
    };
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:34,代码来源:OperatorSkipTimed.java

示例6: call

import rx.Scheduler.Worker; //导入方法依赖的package包/类
public void call(final Subscriber<? super T> s) {
    Worker worker = this.scheduler.createWorker();
    s.add(worker);
    worker.schedule(new Action0() {
        public void call() {
            if (!s.isUnsubscribed()) {
                OnSubscribeDelaySubscription.this.source.unsafeSubscribe(Subscribers.wrap(s));
            }
        }
    }, this.time, this.unit);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:OnSubscribeDelaySubscription.java

示例7: call

import rx.Scheduler.Worker; //导入方法依赖的package包/类
public void call(final Subscriber<? super Long> child) {
    Worker worker = this.scheduler.createWorker();
    child.add(worker);
    worker.schedule(new Action0() {
        public void call() {
            try {
                child.onNext(Long.valueOf(0));
                child.onCompleted();
            } catch (Throwable t) {
                Exceptions.throwOrReport(t, child);
            }
        }
    }, this.time, this.unit);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:OnSubscribeTimerOnce.java

示例8: call

import rx.Scheduler.Worker; //导入方法依赖的package包/类
public Subscriber<? super T> call(Subscriber<? super T> child) {
    Worker worker = this.scheduler.createWorker();
    child.add(worker);
    TakeSubscriber<T> ts = new TakeSubscriber(new SerializedSubscriber(child));
    worker.schedule(ts, this.time, this.unit);
    return ts;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:OperatorTakeTimed.java

示例9: call

import rx.Scheduler.Worker; //导入方法依赖的package包/类
public Subscription call(final TimeoutSubscriber<T> timeoutSubscriber, final Long seqId, Worker inner) {
    return inner.schedule(new Action0() {
        public void call() {
            timeoutSubscriber.onTimeout(seqId.longValue());
        }
    }, this.val$timeout, this.val$timeUnit);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:OperatorTimeout.java

示例10: call

import rx.Scheduler.Worker; //导入方法依赖的package包/类
public Subscriber<? super T> call(final Subscriber<? super T> child) {
    final Worker worker = this.scheduler.createWorker();
    child.add(worker);
    return new Subscriber<T>(child) {
        boolean done;

        public void onCompleted() {
            worker.schedule(new Action0() {
                public void call() {
                    if (!AnonymousClass1.this.done) {
                        AnonymousClass1.this.done = true;
                        child.onCompleted();
                    }
                }
            }, OperatorDelay.this.delay, OperatorDelay.this.unit);
        }

        public void onError(final Throwable e) {
            worker.schedule(new Action0() {
                public void call() {
                    if (!AnonymousClass1.this.done) {
                        AnonymousClass1.this.done = true;
                        child.onError(e);
                        worker.unsubscribe();
                    }
                }
            });
        }

        public void onNext(final T t) {
            worker.schedule(new Action0() {
                public void call() {
                    if (!AnonymousClass1.this.done) {
                        child.onNext(t);
                    }
                }
            }, OperatorDelay.this.delay, OperatorDelay.this.unit);
        }
    };
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:41,代码来源:OperatorDelay.java

示例11: call

import rx.Scheduler.Worker; //导入方法依赖的package包/类
@Override
public void call(final Subscriber<? super T> subscriber) {
    if (!subscriber.isUnsubscribed()) {
        try {
            final ProxyProducer<T> producer = getProducer(subscriber, mCachedValue.get());
            final Worker worker = mScheduler.createWorker();
            subscriber.add(worker);
            subscriber.setProducer(producer);
            final Callback<T> listener = new Callback<T>() {
                @Override
                public void notify(final T value) {
                    if (!subscriber.isUnsubscribed()) {
                        worker.schedule(new Action0() {
                            @Override
                            public void call() {
                                producer.offer(value);
                            }
                        });
                    }
                }
            };

            addCallback(listener);

            subscriber.add(Subscriptions.create(new Action0() {
                @Override
                public void call() {
                    removeCallback(listener);
                }
            }));
        } catch (RuntimeException e) {
            subscriber.onError(e);
        }
    }
}
 
开发者ID:upday,项目名称:RxProxy,代码行数:36,代码来源:RxPublishProxy.java

示例12: racy

import rx.Scheduler.Worker; //导入方法依赖的package包/类
@Test
public void racy() throws Exception {
    Worker worker = Schedulers.computation().createWorker();
    try {
        for (int i = 0; i < 1000; i++) {
            AtomicInteger wip = new AtomicInteger(2);
    
            PublishSubject<Integer> ps = PublishSubject.create();
            
            AssertableSubscriber<Integer> as = ps.test(1);
            
            CountDownLatch cdl = new CountDownLatch(1);
            
            worker.schedule(() -> {
                if (wip.decrementAndGet() != 0) {
                    while (wip.get() != 0) ;
                }
                ps.onNext(1);
                
                cdl.countDown();
            });
            if (wip.decrementAndGet() != 0) {
                while (wip.get() != 0) ;
            }
            ps.onNext(1);
            
            cdl.await();
            
            as.assertFailure(MissingBackpressureException.class, 1);
        }
    } finally {
        worker.unsubscribe();
    }
}
 
开发者ID:akarnokd,项目名称:akarnokd-misc,代码行数:35,代码来源:PublishSubjectRaceTest.java

示例13: nonRacy

import rx.Scheduler.Worker; //导入方法依赖的package包/类
@Test
public void nonRacy() throws Exception {
    Worker worker = Schedulers.computation().createWorker();
    try {
        for (int i = 0; i < 1000; i++) {
            AtomicInteger wip = new AtomicInteger(2);
    
            Subject<Integer, Integer> ps = PublishSubject.<Integer>create().toSerialized();
            
            AssertableSubscriber<Integer> as = ps.test(1);
            
            CountDownLatch cdl = new CountDownLatch(1);
            
            worker.schedule(() -> {
                if (wip.decrementAndGet() != 0) {
                    while (wip.get() != 0) ;
                }
                ps.onNext(1);
                
                cdl.countDown();
            });
            if (wip.decrementAndGet() != 0) {
                while (wip.get() != 0) ;
            }
            ps.onNext(1);
            
            cdl.await();
            
            as.assertFailure(MissingBackpressureException.class, 1);
        }
    } finally {
        worker.unsubscribe();
    }
}
 
开发者ID:akarnokd,项目名称:akarnokd-misc,代码行数:35,代码来源:PublishSubjectRaceTest.java

示例14: call

import rx.Scheduler.Worker; //导入方法依赖的package包/类
@Override
public Subscriber<? super T> call(final Subscriber<? super T> child) {
    final Worker worker = scheduler.createWorker();
    child.add(worker);
    final AtomicBoolean gate = new AtomicBoolean();
    worker.schedule(new Action0() {
        @Override
        public void call() {
            gate.set(true);
        }
    }, time, unit);
    return new Subscriber<T>(child) {

        @Override
        public void onNext(T t) {
            if (gate.get()) {
                child.onNext(t);
            }
        }

        @Override
        public void onError(Throwable e) {
            try {
                child.onError(e);
            } finally {
                unsubscribe();
            }
        }

        @Override
        public void onComplete() {
            try {
                child.onComplete();
            } finally {
                unsubscribe();
            }
        }
    };
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:40,代码来源:OperatorSkipTimed.java

示例15: call

import rx.Scheduler.Worker; //导入方法依赖的package包/类
@Override
public void call(final Subscriber<? super T> s) {
    final Worker worker = scheduler.createWorker();
    s.add(worker);

    worker.schedule(new Action0() {
        @Override
        public void call() {
            if (!s.isUnsubscribed()) {
                source.unsafeSubscribe(s);
            }
        }
    }, time, unit);
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:15,代码来源:OnSubscribeDelaySubscription.java


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