1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-01-18 20:01:48 +01:00

Add methods to check LocalWaker registration state

This commit is contained in:
Nikolay Kim 2019-12-20 09:13:11 +06:00
parent 0d3f9e74c5
commit 05549f0b42
4 changed files with 21 additions and 8 deletions

View File

@ -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"] }

View File

@ -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

View File

@ -1,6 +1,6 @@
[package]
name = "actix-utils"
version = "1.0.3"
version = "1.0.4"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
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"

View File

@ -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
}
}