ref: make Context::alloc_ongoing return a guard

This guard can be awaited and will resolve when Context::stop_ongoing
is called, i.e. the ongoing process is cancelled.  The guard will also
free the ongoing process when dropped, making it RAII and easier to
not accidentally free the ongoing process.
This commit is contained in:
Floris Bruynooghe
2023-03-30 10:32:08 +02:00
parent 3400f5641e
commit 0c5d1832ae
4 changed files with 124 additions and 43 deletions

View File

@@ -94,7 +94,7 @@ pub async fn imex(
let _guard = context.scheduler.pause(context.clone()).await;
imex_inner(context, what, path, passphrase)
.race(async {
cancel.recv().await.ok();
cancel.await;
Err(format_err!("canceled"))
})
.await