Explicitly test that data will stay available and can be retrieved
immediately via listen(), even if the future producing the data and
notifying the consumers was already run in the past.
Wasn't broken or anything, but helps with understanding IMO.
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
let result = CHECKSUM.load(Ordering::SeqCst);
assert_eq!(result, 3);
+
+ // the result stays available until the BroadcastFuture is dropped
+ rt.block_on(sender.listen()
+ .map_ok(|res| {
+ CHECKSUM.fetch_add(res*4, Ordering::SeqCst);
+ })
+ .map_err(|err| { panic!("got error {}", err); })
+ .map(|_| ()));
+
+ let result = CHECKSUM.load(Ordering::SeqCst);
+ assert_eq!(result, 7);
}