Use new values api (#521)

This commit is contained in:
Nikolay Kim 2025-03-13 17:42:59 +05:00 committed by GitHub
parent cfc32ed74f
commit ab5fb624b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 55 additions and 79 deletions

View file

@ -45,7 +45,8 @@ ntex-util = { path = "ntex-util" }
ntex-compio = { path = "ntex-compio" }
ntex-tokio = { path = "ntex-tokio" }
ntex-neon = { git = "https://github.com/ntex-rs/neon.git" }
#ntex-neon = { git = "https://github.com/ntex-rs/neon.git" }
#ntex-neon = { path = "../dev/neon" }
[workspace.dependencies]
async-task = "4.5.0"

View file

@ -90,10 +90,7 @@ struct ConnectOpsInner {
impl ConnectOps {
pub(crate) fn current() -> Self {
Runtime::with_current(|rt| {
if let Some(s) = rt.get::<Self>() {
s
} else {
Runtime::value(|rt| {
let mut inner = None;
rt.driver().register(|api| {
let ops = Rc::new(ConnectOpsInner {
@ -107,10 +104,7 @@ impl ConnectOps {
})
});
let s = ConnectOps(inner.unwrap());
rt.insert(s.clone());
s
}
ConnectOps(inner.unwrap())
})
}

View file

@ -52,10 +52,7 @@ struct StreamOpsInner<T> {
impl<T: AsRawFd + 'static> StreamOps<T> {
pub(crate) fn current() -> Self {
Runtime::with_current(|rt| {
if let Some(s) = rt.get::<Self>() {
s
} else {
Runtime::value(|rt| {
let mut inner = None;
rt.driver().register(|api| {
let ops = Rc::new(StreamOpsInner {
@ -70,10 +67,7 @@ impl<T: AsRawFd + 'static> StreamOps<T> {
})
});
let s = StreamOps(inner.unwrap());
rt.insert(s.clone());
s
}
StreamOps(inner.unwrap())
})
}

View file

@ -85,10 +85,7 @@ struct ConnectOpsInner {
impl ConnectOps {
pub(crate) fn current() -> Self {
Runtime::with_current(|rt| {
if let Some(s) = rt.get::<Self>() {
s
} else {
Runtime::value(|rt| {
let mut inner = None;
rt.driver().register(|api| {
let ops = Rc::new(ConnectOpsInner {
@ -98,11 +95,7 @@ impl ConnectOps {
inner = Some(ops.clone());
Box::new(ConnectOpsHandler { inner: ops })
});
let s = ConnectOps(inner.unwrap());
rt.insert(s.clone());
s
}
ConnectOps(inner.unwrap())
})
}

View file

@ -59,10 +59,7 @@ struct StreamOpsStorage<T> {
impl<T: AsRawFd + 'static> StreamOps<T> {
pub(crate) fn current() -> Self {
Runtime::with_current(|rt| {
if let Some(s) = rt.get::<Self>() {
s
} else {
Runtime::value(|rt| {
let mut inner = None;
rt.driver().register(|api| {
let mut ops = Slab::new();
@ -80,10 +77,7 @@ impl<T: AsRawFd + 'static> StreamOps<T> {
Box::new(StreamOpsHandler { inner: ops })
});
let s = StreamOps(inner.unwrap());
rt.insert(s.clone());
s
}
StreamOps(inner.unwrap())
})
}