Merge pull request #214 from lulf/agnostic-non-mut-waker

Allow non-mut register and wake
This commit is contained in:
Dario Nieuwenhuis 2021-06-01 15:41:36 +02:00 committed by GitHub
commit 4c03fdb094
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,7 +61,7 @@ impl AtomicWaker {
}
/// Register a waker. Overwrites the previous waker, if any.
pub fn register(&mut self, w: &Waker) {
pub fn register(&self, w: &Waker) {
critical_section::with(|cs| {
let cell = self.waker.borrow(cs);
cell.set(match cell.replace(None) {
@ -72,7 +72,7 @@ impl AtomicWaker {
}
/// Wake the registered waker, if any.
pub fn wake(&mut self) {
pub fn wake(&self) {
critical_section::with(|cs| {
let cell = self.waker.borrow(cs);
if let Some(w) = cell.replace(None) {