Skip to content

Commit

Permalink
[runtime] Enhancement: Simplify remove_coroutine_and_get_result()
Browse files Browse the repository at this point in the history
  • Loading branch information
anandbonde committed Nov 25, 2023
1 parent 6274599 commit 4c6eea7
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/rust/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,7 @@ impl SharedDemiRuntime {
/// Removes a coroutine from the underlying scheduler given its associated [TaskHandle] `handle`
/// and gets the result immediately.
pub fn remove_coroutine_and_get_result(&mut self, handle: &TaskHandle, qt: u64) -> demi_qresult_t {
// 1. Remove Task from scheduler.
let boxed_task: Box<dyn Task> = self
.scheduler
.remove(handle)
.expect("Removing task that does not exist (either was previously removed or never inserted");
// 2. Cast to void and then downcast to operation task.
trace!("Removing coroutine: {:?}", boxed_task.get_name());
let operation_task: OperationTask = OperationTask::from(boxed_task.as_any());
let operation_task: OperationTask = self.remove_coroutine(handle);
let (qd, result) = operation_task.get_result().expect("Coroutine not finished");
self.pack_result(result, qd, qt)
}
Expand Down

0 comments on commit 4c6eea7

Please sign in to comment.