Replace rt::spawn with trait to handle spawning task
Add a JoinHandle to return results when awaiting on a value from a task
Which issue(s) this PR fixes 🔨
Special notes for reviewers 🗒️
Additional comments 🎤
While previously, we were able to use rt::spawn, which was an alias between tokio::spawn on native and wasm_bindgen_futures::spawn_local for wasm32, we were not able to await the task for the latter since it does not return an handle. This PR introduces a trait with a basic interface that allows us to implement an executor to be able to spawn a task, with a function Executor::spawn returning a JoinHandle<T>, with wasm32 having a holder for a oneshot channel that is awaited on if the JohnHandle is awaited, or just spawning a task without returning anything with Executor::dispatch.
Additionally, this would allow us to make use of different executors internally when needed, mostly for tests.
What this PR does 📖
rt::spawn
with trait to handle spawning taskJoinHandle
to return results when awaiting on a value from a taskWhich issue(s) this PR fixes 🔨
Special notes for reviewers 🗒️
Additional comments 🎤
rt::spawn
, which was an alias betweentokio::spawn
on native andwasm_bindgen_futures::spawn_local
for wasm32, we were not able to await the task for the latter since it does not return an handle. This PR introduces a trait with a basic interface that allows us to implement an executor to be able to spawn a task, with a functionExecutor::spawn
returning aJoinHandle<T>
, with wasm32 having a holder for a oneshot channel that is awaited on if theJohnHandle
is awaited, or just spawning a task without returning anything withExecutor::dispatch
.