Exemplo n.º 1
0
 public static Observable<Long> interval(
     long period, TimeUnit unit, BackedScheduler scheduler, IUpdateCollector updateCollector) {
   return Observable.<Long>create(
           o -> {
             BackedWorker<Subscriber<? super Long>> worker =
                 scheduler.createWorker(o, updateCollector);
             if (!MachineContext.get().recovering) {
               worker.schedulePeriodicallyBacked(
                   child -> {
                     child.onNext(0L);
                   },
                   period,
                   period,
                   unit,
                   "interval",
                   "infinite");
             } else {
               o.onNext(0L); // feed skip(1)
               LOG.info("interval recovered");
             }
             o.add(worker);
           })
       .lift(ScanOperator.create(-1L, (s, v) -> s + 1, updateCollector))
       .skip(1);
 }
Exemplo n.º 2
0
 public static Observable<?> pulse(
     long period, TimeUnit unit, BackedScheduler scheduler, IUpdateCollector updateCollector) {
   return Observable.create(
       o -> {
         BackedWorker<Subscriber<?>> worker = scheduler.createWorker(o, updateCollector);
         worker.schedulePeriodicallyBacked(
             child -> {
               child.onNext(null);
             },
             period,
             period,
             unit,
             "pulse",
             "infinite");
         o.add(worker);
       });
 }