pub fn run<F, T>(future: F) -> Result<TaskHandler, Error>Expand description
Runs a given future as a Tokio task while ensuring the main function (marked by #[hermes_five::runtime])
will not finish before all tasks running as done.
This is done by using a globally accessible channel to communicate the handlers to be waited by the
runtime.
§Parameters
future: A future that implementsFuture<Output = ()>,Send, and has a'staticlifetime.
§Errors
Returns an error if the lock cannot be acquired or if the sender is not initialized or if sending the task handle fails.
§Example
use hermes_five::utils::task;
#[hermes_five::runtime]
async fn main() {
let handler = task::run(async move {
// whatever
}).unwrap();
// Abort the task early.
handler.abort();
}