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
)