Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouples getting the latest `watch` value from receiving the change notification. The `Receiver` async method becomes `Receiver::changed()`. The latest value is obtained from `Receiver::borrow()`. The implementation is updated to use `Notify`. This requires adding `Notify::notify_waiters`. This method is generally useful but is kept private for now.
- Loading branch information
1 parent
c5a9ede
commit 2bc9a48
Showing
8 changed files
with
281 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use crate::sync::watch; | ||
|
||
use loom::future::block_on; | ||
use loom::thread; | ||
|
||
#[test] | ||
fn smoke() { | ||
loom::model(|| { | ||
let (tx, mut rx) = watch::channel(1); | ||
|
||
let th = thread::spawn(move || { | ||
tx.send(2).unwrap(); | ||
}); | ||
|
||
block_on(rx.changed()).unwrap(); | ||
assert_eq!(*rx.borrow(), 2); | ||
|
||
th.join().unwrap(); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ cfg_loom! { | |
mod loom_oneshot; | ||
mod loom_semaphore_batch; | ||
mod loom_semaphore_ll; | ||
mod loom_watch; | ||
} |
Oops, something went wrong.