pub unsafe fn spawn_unchecked<F, S>(
    future: F,
    schedule: S
) -> (Runnable, Task<F::Output>)
where F: Future, S: Fn(Runnable),
Expand description

Creates a new task without Send, Sync, and 'static bounds.

This function is same as spawn(), except it does not require Send, Sync, and 'static on future and schedule.

Safety

  • If future is not Send, its Runnable must be used and dropped on the original thread.
  • If future is not 'static, borrowed variables must outlive its Runnable.
  • If schedule is not Send and Sync, the task’s Waker must be used and dropped on the original thread.
  • If schedule is not 'static, borrowed variables must outlive the task’s Waker.

Examples

// The future inside the task.
let future = async {
    println!("Hello, world!");
};

// If the task gets woken up, it will be sent into this channel.
let (s, r) = flume::unbounded();
let schedule = move |runnable| s.send(runnable).unwrap();

// Create a task with the future and the schedule function.
let (runnable, task) = unsafe { async_task::spawn_unchecked(future, schedule) };