pub struct SendSpawner { /* private fields */ }
Expand description
Handle to spawn tasks into an executor from any thread.
This Spawner can be used from any thread (it is Send), but it can only spawn Send tasks. The reason for this is spawning is effectively “sending” the tasks to the executor thread.
If you want to spawn non-Send tasks, use Spawner.
Implementations§
source§impl SendSpawner
impl SendSpawner
sourcepub async fn for_current_executor() -> Self
pub async fn for_current_executor() -> Self
Get a Spawner for the current executor.
This function is async
just to get access to the current async
context. It returns instantly, it does not block/yield.
§Panics
Panics if the current executor is not an Embassy executor.
sourcepub fn spawn<S: Send>(&self, token: SpawnToken<S>) -> Result<(), SpawnError>
pub fn spawn<S: Send>(&self, token: SpawnToken<S>) -> Result<(), SpawnError>
Spawn a task into an executor.
You obtain the token
by calling a task function (i.e. one marked with #[embassy_executor::task]
).
sourcepub fn must_spawn<S: Send>(&self, token: SpawnToken<S>)
pub fn must_spawn<S: Send>(&self, token: SpawnToken<S>)
Trait Implementations§
source§impl Clone for SendSpawner
impl Clone for SendSpawner
source§fn clone(&self) -> SendSpawner
fn clone(&self) -> SendSpawner
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreimpl Copy for SendSpawner
Auto Trait Implementations§
impl Freeze for SendSpawner
impl RefUnwindSafe for SendSpawner
impl Send for SendSpawner
impl Sync for SendSpawner
impl Unpin for SendSpawner
impl UnwindSafe for SendSpawner
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)