Is there any broadcast oneshot channel which combines both oneshot
and broadcast
.
It can be useful to implement the "shutdown" signal.
Is there any broadcast oneshot channel which combines both oneshot
and broadcast
.
It can be useful to implement the "shutdown" signal.
If your goal is to implement shutdown, then see the graceful shutdown page from the Tokio tutorial.
One type that isn't mentioned on that site, by probably should be, is the CancellationToken
.
Thanks a lot for mentioning this. In past, I was tempted to use an Arc<()>
to terminate a thread, but CancellationToken
seems to be a better choice (plus it allows asynchronous await
ing).
From the linked thread:
I guess CancellationToken
is exactly what I was looking for, right? I tried to update the example of my OP in the other thread: Playground.
Using a cancellation token is definitely better than an Arc<()>
, because the token has a way to notify the thread that it should shut down.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.