user internal access to reduce Clone cost

This commit is contained in:
fakeshadow 2021-04-17 13:21:56 +08:00
parent 07dec1efa4
commit e6944c52d1
1 changed files with 8 additions and 3 deletions

View File

@ -157,10 +157,15 @@ impl System {
{
tokio::spawn(async {
let (tx, rx) = oneshot::channel();
System::current().arbiter().spawn(async move {
let res = tokio::spawn(task).await;
let _ = tx.send(res);
CURRENT.with(|cell| match *cell.borrow() {
Some(ref sys) => sys.arbiter_handle.spawn(async {
let res = tokio::spawn(task).await;
let _ = tx.send(res);
}),
None => panic!("System is not running"),
});
// unwrap would be caught by tokio and output as JoinError
rx.await.unwrap().unwrap()
})