本文整理汇总了Java中rx.Scheduler.Worker.schedulePeriodically方法的典型用法代码示例。如果您正苦于以下问题:Java Worker.schedulePeriodically方法的具体用法?Java Worker.schedulePeriodically怎么用?Java Worker.schedulePeriodically使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.Scheduler.Worker
的用法示例。
在下文中一共展示了Worker.schedulePeriodically方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import rx.Scheduler.Worker; //导入方法依赖的package包/类
public void call(final Subscriber<? super Long> child) {
final Worker worker = this.scheduler.createWorker();
child.add(worker);
worker.schedulePeriodically(new Action0() {
long counter;
public void call() {
try {
Subscriber subscriber = child;
long j = this.counter;
this.counter = 1 + j;
subscriber.onNext(Long.valueOf(j));
} catch (Throwable e) {
worker.unsubscribe();
} finally {
Exceptions.throwOrReport(e, child);
}
}
}, this.initialDelay, this.period, this.unit);
}
示例2: start
import rx.Scheduler.Worker; //导入方法依赖的package包/类
public void start() {
Worker w = Schedulers.computation().createWorker();
if (this.schedulerWorker.compareAndSet(null, w)) {
w.schedulePeriodically(new Action0() {
public void call() {
int size = ObjectPool.this.pool.size();
int i;
if (size < ObjectPool.this.minSize) {
int sizeToBeAdded = ObjectPool.this.maxSize - size;
for (i = 0; i < sizeToBeAdded; i++) {
ObjectPool.this.pool.add(ObjectPool.this.createObject());
}
} else if (size > ObjectPool.this.maxSize) {
int sizeToBeRemoved = size - ObjectPool.this.maxSize;
for (i = 0; i < sizeToBeRemoved; i++) {
ObjectPool.this.pool.poll();
}
}
}
}, this.validationInterval, this.validationInterval, TimeUnit.SECONDS);
} else {
w.unsubscribe();
}
}
示例3: call
import rx.Scheduler.Worker; //导入方法依赖的package包/类
@Override
public void call(final Subscriber<? super Long> child) {
final Worker worker = scheduler.createWorker();
child.add(worker);
worker.schedulePeriodically(new Action0() {
long counter;
@Override
public void call() {
try {
child.onNext(counter++);
} catch (Throwable e) {
try {
child.onError(e);
} finally {
worker.unsubscribe();
}
}
}
}, initialDelay, period, unit);
}
示例4: call
import rx.Scheduler.Worker; //导入方法依赖的package包/类
public Subscriber<? super T> call(Subscriber<? super T> child) {
SerializedSubscriber<T> s = new SerializedSubscriber(child);
Worker worker = this.scheduler.createWorker();
child.add(worker);
SamplerSubscriber<T> sampler = new SamplerSubscriber(s);
child.add(sampler);
worker.schedulePeriodically(sampler, this.time, this.time, this.unit);
return sampler;
}
示例5: call
import rx.Scheduler.Worker; //导入方法依赖的package包/类
@Override
public Subscriber<? super T> call(Subscriber<? super T> child) {
final SerializedSubscriber<T> s = new SerializedSubscriber<T>(child);
final Worker worker = scheduler.createWorker();
child.add(worker);
SamplerSubscriber<T> sampler = new SamplerSubscriber<T>(s);
child.add(sampler);
worker.schedulePeriodically(sampler, time, time, unit);
return sampler;
}
示例6: call
import rx.Scheduler.Worker; //导入方法依赖的package包/类
@Override
public Subscriber<? super T> call(Subscriber<? super T> child) {
final SerializedSubscriber<T> s = new SerializedSubscriber<T>(child);
final Worker worker = scheduler.createWorker();
child.add(worker);
SamplerSubscriber<T> sampler = new SamplerSubscriber<T>(s);
worker.schedulePeriodically(sampler, time, time, unit);
return sampler;
}