You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a Vec<Arc<JoinHandle<()>>> is used, note that Arc<JoinHandle<()>> is not aFuture, so it would need to be changed in order to use futures::future::join_all.
The traits OfaFullRuntime, Spawner will need to be refactored as they currently return Box<dyn TaskHandle> and JoinHandle<()> does not implement Copy or Clone. Creating the TokioTaskHandle, adding an Arc to the vector and returning the TokioTaskHandle is not possible due to a borrow error:
let tokio_handle = TokioTaskHandle(join_handle); // Moved join_handle
let arc_handle = Arc::new(tokio_handle);
handles.push(Arc::clone(&arc_handle));
Box::new(tokio_handle) // Error caused by previous move
The method spawn() of OfaFullRuntime does not take a mutable reference to self so it would not be possible to simply add a Vec<Arc<JoinHandle<()>>> field to TokioRuntimeContext.
For Admin Use
Not duplicate issue
Appropriate labels applied
Appropriate milestone (priority) applied
Appropriate contributors tagged
Contributor assigned/self-assigned
The text was updated successfully, but these errors were encountered:
Proposal
The runtime implementation for relayer-next should be updated in order to abort all spawned tasks.
The implementation of
TokioRuntimeContext
in the relayer-next spawns a new task does not have any method to abort all spawned tasks, https://github.com/informalsystems/hermes/blob/soares/relayer-next/crates/relayer-runtime/src/tokio/context.rs#L24.One of the use cases for this feature is when running the integration tests with the relayer-next. The current solution only aborts the
JoinHandle<()>
of theauto_relay()
task spawned, https://github.com/informalsystems/hermes/pull/3234/files#diff-50ab12b7fc99fc8b4406c1de2f36eae74380960d5049fe0ec3df3c92c1495f32R421.Being able to cleanly abort all tasks from the context instead would be better.
One solution could be to keep track of all
JoinHandle<()>
spawned, https://github.com/informalsystems/hermes/blob/soares/relayer-next/crates/relayer-runtime/src/tokio/context.rs#L95, and have a method abort them and wait for all the tasks to be finished.A few issues need to be considered for the refactoring:
Vec<Arc<JoinHandle<()>>>
is used, note thatArc<JoinHandle<()>>
is not aFuture
, so it would need to be changed in order to usefutures::future::join_all
.OfaFullRuntime
,Spawner
will need to be refactored as they currently returnBox<dyn TaskHandle>
andJoinHandle<()>
does not implementCopy
orClone
. Creating theTokioTaskHandle
, adding anArc
to the vector and returning theTokioTaskHandle
is not possible due to a borrow error:spawn()
ofOfaFullRuntime
does not take a mutable reference toself
so it would not be possible to simply add aVec<Arc<JoinHandle<()>>>
field toTokioRuntimeContext
.For Admin Use
The text was updated successfully, but these errors were encountered: