mirror of https://github.com/fafhrd91/actix-net
user internal access to reduce Clone cost
This commit is contained in:
parent
07dec1efa4
commit
e6944c52d1
|
@ -157,10 +157,15 @@ impl System {
|
||||||
{
|
{
|
||||||
tokio::spawn(async {
|
tokio::spawn(async {
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
System::current().arbiter().spawn(async move {
|
|
||||||
|
CURRENT.with(|cell| match *cell.borrow() {
|
||||||
|
Some(ref sys) => sys.arbiter_handle.spawn(async {
|
||||||
let res = tokio::spawn(task).await;
|
let res = tokio::spawn(task).await;
|
||||||
let _ = tx.send(res);
|
let _ = tx.send(res);
|
||||||
|
}),
|
||||||
|
None => panic!("System is not running"),
|
||||||
});
|
});
|
||||||
|
|
||||||
// unwrap would be caught by tokio and output as JoinError
|
// unwrap would be caught by tokio and output as JoinError
|
||||||
rx.await.unwrap().unwrap()
|
rx.await.unwrap().unwrap()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue