mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-03 21:07:39 +03:00
Use new values api (#521)
This commit is contained in:
parent
cfc32ed74f
commit
ab5fb624b7
5 changed files with 55 additions and 79 deletions
|
@ -45,7 +45,8 @@ ntex-util = { path = "ntex-util" }
|
||||||
ntex-compio = { path = "ntex-compio" }
|
ntex-compio = { path = "ntex-compio" }
|
||||||
ntex-tokio = { path = "ntex-tokio" }
|
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]
|
[workspace.dependencies]
|
||||||
async-task = "4.5.0"
|
async-task = "4.5.0"
|
||||||
|
|
|
@ -90,10 +90,7 @@ struct ConnectOpsInner {
|
||||||
|
|
||||||
impl ConnectOps {
|
impl ConnectOps {
|
||||||
pub(crate) fn current() -> Self {
|
pub(crate) fn current() -> Self {
|
||||||
Runtime::with_current(|rt| {
|
Runtime::value(|rt| {
|
||||||
if let Some(s) = rt.get::<Self>() {
|
|
||||||
s
|
|
||||||
} else {
|
|
||||||
let mut inner = None;
|
let mut inner = None;
|
||||||
rt.driver().register(|api| {
|
rt.driver().register(|api| {
|
||||||
let ops = Rc::new(ConnectOpsInner {
|
let ops = Rc::new(ConnectOpsInner {
|
||||||
|
@ -107,10 +104,7 @@ impl ConnectOps {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let s = ConnectOps(inner.unwrap());
|
ConnectOps(inner.unwrap())
|
||||||
rt.insert(s.clone());
|
|
||||||
s
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,7 @@ struct StreamOpsInner<T> {
|
||||||
|
|
||||||
impl<T: AsRawFd + 'static> StreamOps<T> {
|
impl<T: AsRawFd + 'static> StreamOps<T> {
|
||||||
pub(crate) fn current() -> Self {
|
pub(crate) fn current() -> Self {
|
||||||
Runtime::with_current(|rt| {
|
Runtime::value(|rt| {
|
||||||
if let Some(s) = rt.get::<Self>() {
|
|
||||||
s
|
|
||||||
} else {
|
|
||||||
let mut inner = None;
|
let mut inner = None;
|
||||||
rt.driver().register(|api| {
|
rt.driver().register(|api| {
|
||||||
let ops = Rc::new(StreamOpsInner {
|
let ops = Rc::new(StreamOpsInner {
|
||||||
|
@ -70,10 +67,7 @@ impl<T: AsRawFd + 'static> StreamOps<T> {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let s = StreamOps(inner.unwrap());
|
StreamOps(inner.unwrap())
|
||||||
rt.insert(s.clone());
|
|
||||||
s
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,7 @@ struct ConnectOpsInner {
|
||||||
|
|
||||||
impl ConnectOps {
|
impl ConnectOps {
|
||||||
pub(crate) fn current() -> Self {
|
pub(crate) fn current() -> Self {
|
||||||
Runtime::with_current(|rt| {
|
Runtime::value(|rt| {
|
||||||
if let Some(s) = rt.get::<Self>() {
|
|
||||||
s
|
|
||||||
} else {
|
|
||||||
let mut inner = None;
|
let mut inner = None;
|
||||||
rt.driver().register(|api| {
|
rt.driver().register(|api| {
|
||||||
let ops = Rc::new(ConnectOpsInner {
|
let ops = Rc::new(ConnectOpsInner {
|
||||||
|
@ -98,11 +95,7 @@ impl ConnectOps {
|
||||||
inner = Some(ops.clone());
|
inner = Some(ops.clone());
|
||||||
Box::new(ConnectOpsHandler { inner: ops })
|
Box::new(ConnectOpsHandler { inner: ops })
|
||||||
});
|
});
|
||||||
|
ConnectOps(inner.unwrap())
|
||||||
let s = ConnectOps(inner.unwrap());
|
|
||||||
rt.insert(s.clone());
|
|
||||||
s
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,7 @@ struct StreamOpsStorage<T> {
|
||||||
|
|
||||||
impl<T: AsRawFd + 'static> StreamOps<T> {
|
impl<T: AsRawFd + 'static> StreamOps<T> {
|
||||||
pub(crate) fn current() -> Self {
|
pub(crate) fn current() -> Self {
|
||||||
Runtime::with_current(|rt| {
|
Runtime::value(|rt| {
|
||||||
if let Some(s) = rt.get::<Self>() {
|
|
||||||
s
|
|
||||||
} else {
|
|
||||||
let mut inner = None;
|
let mut inner = None;
|
||||||
rt.driver().register(|api| {
|
rt.driver().register(|api| {
|
||||||
let mut ops = Slab::new();
|
let mut ops = Slab::new();
|
||||||
|
@ -80,10 +77,7 @@ impl<T: AsRawFd + 'static> StreamOps<T> {
|
||||||
Box::new(StreamOpsHandler { inner: ops })
|
Box::new(StreamOpsHandler { inner: ops })
|
||||||
});
|
});
|
||||||
|
|
||||||
let s = StreamOps(inner.unwrap());
|
StreamOps(inner.unwrap())
|
||||||
rt.insert(s.clone());
|
|
||||||
s
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue