pub struct CoroutineContext<SerializedData: 'static + Send> {
pub serializer: Serializer<(CoroutineSharedData, SerializedData)>,
pub task_id: u32,
/* private fields */
}Expand description
Context of one coroutine/task
Fields§
§serializer: Serializer<(CoroutineSharedData, SerializedData)>Data shared by all tasks in the same serialization group.
task_id: u32Task ID of the current task. 0 implies main task, while other values are used for
children tasks.
Implementations§
Source§impl<SD: 'static + Send> CoroutineContext<SD>
impl<SD: 'static + Send> CoroutineContext<SD>
Sourcepub async fn main_context(shared_data: SD) -> Self
pub async fn main_context(shared_data: SD) -> Self
Creates a new, main coroutine context with given shared_data
pub fn child_context( serializer: Serializer<(CoroutineSharedData, SD)>, permit: SerializerLock<'static, (CoroutineSharedData, SD)>, task_id: u32, ) -> Self
Given the fact that the permit is held, and there’s not another mutable reference to the shared data, retrieve the shared data.
Sourcepub async fn co_await<FUT, RET>(&self, fut: FUT) -> RET
pub async fn co_await<FUT, RET>(&self, fut: FUT) -> RET
Interrupt current task, await for given fut. During this time other tasks may run.
Sourcepub async fn co_spawn_task<FN, ARGS, FUT, RET>(
&self,
f: FN,
args: ARGS,
) -> JoinHandle<RET>
pub async fn co_spawn_task<FN, ARGS, FUT, RET>( &self, f: FN, args: ARGS, ) -> JoinHandle<RET>
Spawn a new task managed by the current serialization group
Trait Implementations§
Source§impl<SD: 'static + Send> Drop for CoroutineContext<SD>
impl<SD: 'static + Send> Drop for CoroutineContext<SD>
impl<SD: 'static + Send> Send for CoroutineContext<SD>
impl<SD: 'static + Send> Sync for CoroutineContext<SD>
Auto Trait Implementations§
impl<SerializedData> !Freeze for CoroutineContext<SerializedData>
impl<SerializedData> !RefUnwindSafe for CoroutineContext<SerializedData>
impl<SerializedData> !UnwindSafe for CoroutineContext<SerializedData>
impl<SerializedData> Unpin for CoroutineContext<SerializedData>
impl<SerializedData> UnsafeUnpin for CoroutineContext<SerializedData>
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