-
Notifications
You must be signed in to change notification settings - Fork 136
Type Interfaces : ReactiveTask
johnmcclean-aol edited this page Nov 23, 2016
·
1 revision
A ReactiveTask represents a currently executing task that callers can control in some manner. It extends Reactive Streams Subscription.
ReactiveTask contains the following methods
- block - Block until the currently active reactive task completes
- cancel - cancel the currently active task
- isCurrentTaskComplete - check if task is complete
- isStreamComplete - check if full Stream is complete
- request - request n elements
- requestAll - request all elements
- requestAllAsync - request all elements asynchronously
- requestAsync - request n elements asynchronously
ReactiveTask s = ReactiveSeq.of(1,2,3)
.futureOperations(exec)
.forEachX( 2, System.out::println);
System.out.println("first batch");
s.request(1);
s.block();
List<Integer> list = new ArrayList<>();
ReactiveTask s = ReactiveSeq.of(1,2,3)
.futureOperations(exec)
.forEachX( 2, i->list.add(i));
s.block();
assertThat(list,hasItems(1,2));
assertThat(list.size(),equalTo(2));
s.requestAllAsync();
//do work
//block to test
s.block();
assertThat(list,hasItems(1,2,3));
assertThat(list.size(),equalTo(3));
ReactiveSeq, LazyFutureStream via ReactiveStreamsTerminalFutureOperations
futureOperations(exec).forEachXXX( );
oops - my bad