本文整理了Java中io.reactivex.Scheduler.now()
方法的一些代码示例,展示了Scheduler.now()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.now()
方法的具体详情如下:
包路径:io.reactivex.Scheduler
类名称:Scheduler
方法名:now
[英]Returns the 'current time' of the Scheduler in the specified time unit.
[中]以指定的时间单位返回计划程序的“当前时间”。
代码示例来源:origin: ReactiveX/RxJava
@Override
public Timed<T> apply(T t) throws Exception {
return new Timed<T>(t, scheduler.now(unit), unit);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSubscribe(Subscription s) {
if (SubscriptionHelper.validate(this.upstream, s)) {
lastTime = scheduler.now(unit);
this.upstream = s;
downstream.onSubscribe(this);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
Object enterTransform(Object value) {
return new Timed<Object>(value, scheduler.now(unit), unit);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
Object enterTransform(Object value) {
return new Timed<Object>(value, scheduler.now(unit), unit);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
final SpscLinkedArrayQueue<Object> q = queue;
long now = scheduler.now(unit);
q.offer(now, t);
trim(now, q);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onComplete() {
trim(scheduler.now(unit), queue);
done = true;
drain();
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
long now = scheduler.now(unit);
long last = lastTime;
lastTime = now;
long delta = now - last;
downstream.onNext(new Timed<T>(t, delta, unit));
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
final SpscLinkedArrayQueue<Object> q = queue;
long now = scheduler.now(unit);
q.offer(now, t);
drain();
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onError(Throwable t) {
if (delayError) {
trim(scheduler.now(unit), queue);
}
error = t;
done = true;
drain();
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onSubscribe(Disposable d) {
if (DisposableHelper.validate(this.upstream, d)) {
this.upstream = d;
lastTime = scheduler.now(unit);
downstream.onSubscribe(this);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
long now = scheduler.now(unit);
queue.offer(now, t);
drain();
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
long now = scheduler.now(unit);
long last = lastTime;
lastTime = now;
long delta = now - last;
downstream.onNext(new Timed<T>(t, delta, unit));
}
代码示例来源:origin: ReactiveX/RxJava
TimedNode<T> getHead() {
TimedNode<T> index = head;
// skip old entries
long limit = scheduler.now(unit) - maxAge;
TimedNode<T> next = index.get();
while (next != null) {
long ts = next.time;
if (ts > limit) {
break;
}
index = next;
next = index.get();
}
return index;
}
代码示例来源:origin: ReactiveX/RxJava
TimedNode<Object> getHead() {
TimedNode<Object> index = head;
// skip old entries
long limit = scheduler.now(unit) - maxAge;
TimedNode<Object> next = index.get();
while (next != null) {
long ts = next.time;
if (ts > limit) {
break;
}
index = next;
next = index.get();
}
return index;
}
代码示例来源:origin: ReactiveX/RxJava
@Override
@Nullable
public T getValue() {
TimedNode<T> h = head;
for (;;) {
TimedNode<T> next = h.get();
if (next == null) {
break;
}
h = next;
}
long limit = scheduler.now(unit) - maxAge;
if (h.time < limit) {
return null;
}
return h.value;
}
代码示例来源:origin: ReactiveX/RxJava
void trim() {
if (size > maxSize) {
size--;
TimedNode<Object> h = head;
head = h.get();
}
long limit = scheduler.now(unit) - maxAge;
TimedNode<Object> h = head;
for (;;) {
TimedNode<Object> next = h.get();
if (next == null) {
head = h;
break;
}
if (next.time > limit) {
head = h;
break;
}
h = next;
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void next(T value) {
TimedNode<T> n = new TimedNode<T>(value, scheduler.now(unit));
TimedNode<T> t = tail;
tail = n;
size++;
t.set(n); // releases both the tail and size
trim();
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void add(T value) {
TimedNode<Object> n = new TimedNode<Object>(value, scheduler.now(unit));
TimedNode<Object> t = tail;
tail = n;
size++;
t.set(n); // releases both the tail and size
trim();
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public long now(@NonNull TimeUnit unit) {
return super.now(unit) + unit.convert(drift, TimeUnit.NANOSECONDS);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
final SpscLinkedArrayQueue<Object> q = queue;
long now = scheduler.now(unit);
long time = this.time;
long c = count;
boolean unbounded = c == Long.MAX_VALUE;
q.offer(now, t);
while (!q.isEmpty()) {
long ts = (Long)q.peek();
if (ts <= now - time || (!unbounded && (q.size() >> 1) > c)) {
q.poll();
q.poll();
} else {
break;
}
}
}
内容来源于网络,如有侵权,请联系作者删除!