-
Notifications
You must be signed in to change notification settings - Fork 136
Type Interfaces : PausableHotStream
johnmcclean-aol edited this page Nov 23, 2016
·
2 revisions
The PausableHotStream interface represents a Stream that is actively emitting values that can be paused it is a subclass of HotStream.
PausableHotStream adds the following methods
- pause - pauses emission from the HotStream.
- unpause - unpauses emission from the HotStream
PausableHotStream<Integer> s = ReactiveSeq.range(0,Integer.MAX_VALUE)
.limitWhile(i->active)
.peek(this::pauseFor1Second)
.pausableHotStream(exec1);
Integer oldValue = value.get();
s.connect()
.limit(10000)
.futureOperations(exec2)
.forEach(System.out::println);
for(int i=0;i<5;i++){
s.pause();
Thread.sleep(3_000);
s.unpause();
Thread.sleep(3_000);
}
PausableHotStream<Integer> s = ReactiveSeq.range(0,Integer.MAX_VALUE)
.primedPausableHotStream(exec);
s.connect()
.forEachX(5,System.out::println);
s.pause();
s.connect()
.forEachX(5000,System.out::println);
//different thread
s.unpause();
ReactiveSeq, LazyFutureStream
## Accessed via
ReactiveSeq#pausableHotStream
LazyFutureStream#pausableHotStream
ReactiveSeq#primedHotStream
LazyFutureStream#primedHotStream
oops - my bad