Open lsk569937453 opened 4 months ago
Current task JoinHandle's output is not something like Result which means the main task can be interrupted, instead, it is returned only if the main task finishes normally.
This can be implemented as you mentioned, but to make it "zero-cost", I think users can do it manually. For example, create a channel and use select!{channel, original_main_task}
as main task. In this way, there's no cost for users which hope it can be run forever, or, hope can exit on certain other things like signal instead of the channel.
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is that I want to shutdown the runtime when it is running on the block_on.
Describe the solution you'd like Maybe we can pass the receiver of channle to the runtime when construct it.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context
Maybe we can pass the stop_rx to the Runtimebuilder,and the runtime will shutdown when the stop_rx receive the message.