rx.Scheduler.now()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中rx.Scheduler.now()方法的一些代码示例,展示了Scheduler.now()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.now()方法的具体详情如下:
包路径:rx.Scheduler
类名称:Scheduler
方法名:now

Scheduler.now介绍

[英]Gets the current time, in milliseconds, according to this Scheduler.
[中]根据此计划程序获取当前时间(以毫秒为单位)。

代码示例

代码示例来源:origin: akarnokd/RxJava2Interop

@Override
public long now(TimeUnit unit) {
  return unit.convert(source.now(), TimeUnit.MILLISECONDS);
}

代码示例来源:origin: akarnokd/RxJava2Interop

@Test
public void now() {
  Scheduler v2Scheduler = mock(Scheduler.class);
  rx.Scheduler v1Scheduler = RxJavaInterop.toV1Scheduler(v2Scheduler);
  when(v2Scheduler.now(MILLISECONDS)).thenReturn(123L);
  assertEquals(123L, v1Scheduler.now());
}

代码示例来源:origin: akarnokd/RxJava2Interop

@Test
public void now() {
  rx.Scheduler v1Scheduler = mock(rx.Scheduler.class);
  io.reactivex.Scheduler v2Scheduler = RxJavaInterop.toV2Scheduler(v1Scheduler);
  when(v1Scheduler.now()).thenReturn(123L);
  assertEquals(123L, v2Scheduler.now(TimeUnit.MILLISECONDS));
}

代码示例来源:origin: com.netflix.rxjava/rxjava-core

@Override
public void onNext(T v) {
  long now = scheduler.now();
  if (lastOnNext == 0 || now - lastOnNext >= timeInMilliseconds) {
    lastOnNext = now;
    subscriber.onNext(v);
  } 
}

代码示例来源:origin: com.github.akarnokd/rxjava2-interop

@Override
public long now(TimeUnit unit) {
  return unit.convert(source.now(), TimeUnit.MILLISECONDS);
}

代码示例来源:origin: com.netflix.rxjava/rxjava-core

@Override
public void onNext(T args) {
  long nowTimestamp = scheduler.now();
  subscriber.onNext(new TimeInterval<T>(nowTimestamp - lastTimestamp, args));
  lastTimestamp = nowTimestamp;
}

代码示例来源:origin: com.netflix.rxjava/rxjava-core

@Override
  public Object call(Object t1) {
    return new Timestamped<Object>(scheduler.now(), t1);
  }
}

代码示例来源:origin: com.netflix.rxjava/rxjava-core

@Override
public void onNext(T t) {
  o.onNext(new Timestamped<T>(scheduler.now(), t));
}

代码示例来源:origin: com.jakewharton.rxrelay/rxrelay

@Override public Object call(Object t1) {
  return new Timestamped<Object>(scheduler.now(), t1);
 }
}

代码示例来源:origin: com.netflix.rxjava/rxjava-core

@Override
public void onNext(T args) {
  long t = scheduler.now();
  timestampBuffer.add(t);
  buffer.add(notification.next(args));
  runEvictionPolicy(t);
}

代码示例来源:origin: com.netflix.eureka2/eureka-client

@Override
public boolean isReadyToSwap(EurekaClientRegistry<InstanceInfo> originalRegistry, EurekaClientRegistry<InstanceInfo> newRegistry) {
  if (originalRegistry.size() == 0) {
    return true;
  }
  if (startTime == -1) {
    startTime = scheduler.now();
  }
  long delay = scheduler.now() - startTime;
  long expectedPercentage = minPercentage - delay / relaxIntervalMs;
  long currentPercentage = newRegistry.size() * 100 / originalRegistry.size();
  return currentPercentage >= expectedPercentage;
}

代码示例来源:origin: com.netflix.rxjava/rxjava-core

@Override
public void onCompleted() {
  emitItemsOutOfWindow(scheduler.now());
  subscriber.onCompleted();
}

代码示例来源:origin: com.netflix.eureka/eureka2-eureka1-rest-api

public void renew() {
  if (v1InstanceInfo != null) {
    this.expiryTime = scheduler.now() + v1InstanceInfo.getLeaseInfo().getDurationInSecs() * 1000;
  }
}

代码示例来源:origin: com.netflix.eureka/eureka2-test-utils

Holder(ChangeNotification<InstanceInfo> notification) {
  this.notification = notification;
  this.timestamp = TopologyFunctions.getTimestamp(notification);
  this.startTime = notification.getKind() == Kind.Add ? timestamp : scheduler.now();
}

代码示例来源:origin: com.netflix.rxjava/rxjava-core

@Override
public void evict(NodeList<Object> t1) {
  long now = scheduler.now();
  while (!t1.isEmpty()) {
    NodeList.Node<Object> n = t1.head.next;
    if (test(n.value, now)) {
      t1.removeFirst();
    } else {
      break;
    }
  }
}

代码示例来源:origin: com.jakewharton.rxrelay/rxrelay

@Override public void evict(NodeList<Object> t1) {
 long now = scheduler.now();
 while (!t1.isEmpty()) {
  NodeList.Node<Object> n = t1.head.next;
  if (test(n.value, now)) {
   t1.removeFirst();
  } else {
   break;
  }
 }
}

代码示例来源:origin: com.netflix.rxjava/rxjava-core

@Override
public void onNext(T value) {
  long now = scheduler.now();
  emitItemsOutOfWindow(now);
  buffer.offerLast(new Timestamped<T>(now, value));
}

代码示例来源:origin: com.netflix.rxjava/rxjava-core

@Override
  public void onCompleted() {
    runEvictionPolicy(scheduler.now());
    timestampBuffer.clear();
    buffer.offer(notification.completed());
    producer.startEmitting();
  }
};

代码示例来源:origin: com.netflix.rxjava/rxjava-core

@Override
public void call(SubjectObserver<T> t1) {
  NodeList.Node<Object> l;
  if (!state.terminated) {
    // ignore stale entries if still active
    l = state.replayObserverFromIndexTest(state.head(), t1, scheduler.now());
  }  else {
    // accept all if terminated
    l = state.replayObserverFromIndex(state.head(), t1);
  }
  t1.index(l);
}

代码示例来源:origin: com.jakewharton.rxrelay/rxrelay

@Override public void call(RelayObserver<T> t1) {
  NodeList.Node<Object> l;
  if (!state.terminated) {
   // ignore stale entries if still active
   l = state.replayObserverFromIndexTest(state.head(), t1, scheduler.now());
  } else {
   // accept all if terminated
   l = state.replayObserverFromIndex(state.head(), t1);
  }
  t1.index(l);
 }
}

相关文章