Skip to content

Type Interfaces : PausableHotStream

johnmcclean-aol edited this page Nov 23, 2016 · 2 revisions

The PausableHotStream interface

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

Examples

One

     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);
         } 

       

Two

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();

Used in

ReactiveSeq, LazyFutureStream

## Accessed via

ReactiveSeq#pausableHotStream
LazyFutureStream#pausableHotStream
ReactiveSeq#primedHotStream
LazyFutureStream#primedHotStream
Clone this wiki locally