From 05549f0b423ef0fc30451c0feeeb220f2c9fa2a5 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 20 Dec 2019 09:13:11 +0600 Subject: [PATCH] Add methods to check LocalWaker registration state --- actix-rt/Cargo.toml | 3 +-- actix-utils/CHANGES.md | 4 ++++ actix-utils/Cargo.toml | 7 +++---- actix-utils/src/task.rs | 15 +++++++++++++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/actix-rt/Cargo.toml b/actix-rt/Cargo.toml index f3305b3b..3ab88ba0 100644 --- a/actix-rt/Cargo.toml +++ b/actix-rt/Cargo.toml @@ -10,7 +10,6 @@ documentation = "https://docs.rs/actix-rt/" categories = ["network-programming", "asynchronous"] license = "MIT/Apache-2.0" edition = "2018" -workspace = ".." [lib] name = "actix_rt" @@ -21,4 +20,4 @@ actix-macros = "0.1.0" actix-threadpool = "0.3" futures = "0.3.1" copyless = "0.1.4" -tokio = { version = "0.2.4", default-features=false, features = ["rt-core", "rt-util", "io-driver", "tcp", "uds", "udp", "time", "signal", "stream"] } +tokio = { version = "0.2.6", default-features=false, features = ["rt-core", "rt-util", "io-driver", "tcp", "uds", "udp", "time", "signal", "stream"] } diff --git a/actix-utils/CHANGES.md b/actix-utils/CHANGES.md index c20a0e76..69f9e514 100644 --- a/actix-utils/CHANGES.md +++ b/actix-utils/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## [1.0.4] - 2019-12-20 + +* Add methods to check `LocalWaker` registration state. + ## [1.0.3] - 2019-12-11 * Revert InOrder service changes diff --git a/actix-utils/Cargo.toml b/actix-utils/Cargo.toml index 78879a79..9b942062 100644 --- a/actix-utils/Cargo.toml +++ b/actix-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-utils" -version = "1.0.3" +version = "1.0.4" authors = ["Nikolay Kim "] description = "Actix utils - various actix net related services" keywords = ["network", "framework", "async", "futures"] @@ -10,7 +10,6 @@ documentation = "https://docs.rs/actix-utils/" categories = ["network-programming", "asynchronous"] license = "MIT/Apache-2.0" edition = "2018" -workspace = ".." [lib] name = "actix_utils" @@ -20,8 +19,8 @@ path = "src/lib.rs" actix-service = "1.0.0" actix-rt = "1.0.0" actix-codec = "0.2.0" -bytes = "0.5.2" -either = "1.5.2" +bytes = "0.5.3" +either = "1.5.3" futures = "0.3.1" pin-project = "0.4.6" log = "0.4" diff --git a/actix-utils/src/task.rs b/actix-utils/src/task.rs index c86378b2..349e3501 100644 --- a/actix-utils/src/task.rs +++ b/actix-utils/src/task.rs @@ -34,11 +34,22 @@ impl LocalWaker { } } + #[inline] + /// Check if waker has been registered. + pub fn is_registed(&self) -> bool { + unsafe { (*self.waker.get()).is_some() } + } + #[inline] /// Registers the waker to be notified on calls to `wake`. - pub fn register(&self, waker: &Waker) { + /// + /// Returns `true` if waker was registered before. + pub fn register(&self, waker: &Waker) -> bool { unsafe { - *self.waker.get() = Some(waker.clone()); + let w = self.waker.get(); + let is_registered = (*w).is_some(); + *w = Some(waker.clone()); + is_registered } }