// An `Arc` is used as the value in order to detect memory leaks. #[test] fn broadcast_two() {
loom::model(|| { let (tx, mut rx1) = broadcast::channel::<Arc<&'static str>>(16); letmut rx2 = tx.subscribe();
let th1 = thread::spawn(move || {
block_on(async { let v = assert_ok!(rx1.recv().await);
assert_eq!(*v, "hello");
let v = assert_ok!(rx1.recv().await);
assert_eq!(*v, "world");
#[test] fn drop_multiple_rx_with_overflow() {
loom::model(move || { // It is essential to have multiple senders and receivers in this test case. let (tx, mut rx) = broadcast::channel(1); let _rx2 = tx.subscribe();
let _ = tx.send(()); let tx2 = tx.clone(); let th1 = thread::spawn(move || {
block_on(async { for _ in0..100 { let _ = tx2.send(());
}
});
}); let _ = tx.send(());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.