mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-06 22:37: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
|
@ -52,28 +52,22 @@ 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 {
|
||||
let mut inner = None;
|
||||
rt.driver().register(|api| {
|
||||
let ops = Rc::new(StreamOpsInner {
|
||||
api,
|
||||
feed: Cell::new(Some(VecDeque::new())),
|
||||
streams: Cell::new(Some(Box::new(Slab::new()))),
|
||||
});
|
||||
inner = Some(ops.clone());
|
||||
Box::new(StreamOpsHandler {
|
||||
inner: ops,
|
||||
feed: VecDeque::new(),
|
||||
})
|
||||
Runtime::value(|rt| {
|
||||
let mut inner = None;
|
||||
rt.driver().register(|api| {
|
||||
let ops = Rc::new(StreamOpsInner {
|
||||
api,
|
||||
feed: Cell::new(Some(VecDeque::new())),
|
||||
streams: Cell::new(Some(Box::new(Slab::new()))),
|
||||
});
|
||||
inner = Some(ops.clone());
|
||||
Box::new(StreamOpsHandler {
|
||||
inner: ops,
|
||||
feed: VecDeque::new(),
|
||||
})
|
||||
});
|
||||
|
||||
let s = StreamOps(inner.unwrap());
|
||||
rt.insert(s.clone());
|
||||
s
|
||||
}
|
||||
StreamOps(inner.unwrap())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue