Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ wasm-bindgen = [
"gloo-timers",
"send_wrapper"
]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(assert_timer_heap_consistent)'] }
15 changes: 7 additions & 8 deletions src/native/atomic_waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ const WAKING: usize = 0b10;
impl AtomicWaker {
/// Create an `AtomicWaker`.
pub fn new() -> AtomicWaker {
// Make sure that task is Sync
trait AssertSync: Sync {}
impl AssertSync for Waker {}

AtomicWaker {
state: AtomicUsize::new(WAITING),
waker: UnsafeCell::new(None),
Expand Down Expand Up @@ -104,8 +100,11 @@ impl AtomicWaker {
/// }
/// ```
pub fn register(&self, waker: &Waker) {
match self.state.compare_and_swap(WAITING, REGISTERING, Acquire) {
WAITING => {
match self
.state
.compare_exchange(WAITING, REGISTERING, Acquire, Acquire)
{
Ok(_) => {
unsafe {
// Locked acquired, update the waker cell
*self.waker.get() = Some(waker.clone());
Expand Down Expand Up @@ -144,13 +143,13 @@ impl AtomicWaker {
}
}
}
WAKING => {
Err(WAKING) => {
// Currently in the process of waking the task, i.e.,
// `wake` is currently being called on the old task handle.
// So, we call wake on the new waker
waker.wake_by_ref();
}
state => {
Err(state) => {
// In this case, a concurrent thread is holding the
// "registering" lock. This probably indicates a bug in the
// caller's code as racing to call `register` doesn't make much
Expand Down