[−][src]Trait context_coroutine::Coroutine
A trait that stackful coroutines should implement.
Start a new instance of this coroutine by using Self::start_coroutine()
.
Associated Types
type StartArguments: Sized
Type of the arguments the coroutine is initially called with, eg (usize, String)
.
type ResumeArguments: Sized
Type of the arguments the coroutine is resumed with, eg (u8, Vec<f64>)
.
type Yields: Sized
Type of the result from a yield of the coroutine.
type Complete: Sized
Type of the final result from the coroutine.
Required methods
fn coroutine<'yielder>(
start_arguments: Self::StartArguments,
yielder: Yielder<'yielder, Self::ResumeArguments, Self::Yields, Self::Complete>
) -> Self::Complete
start_arguments: Self::StartArguments,
yielder: Yielder<'yielder, Self::ResumeArguments, Self::Yields, Self::Complete>
) -> Self::Complete
Implement this for the coroutine's behaviour.
Panics inside the coroutine are transferred to the calling thread and raised.
Provided methods
fn start_coroutine<GTACSA: GlobalThreadAndCoroutineSwitchableAllocator, CoroutineLocalAllocatorConstructor: Fn(RcMemorySource<ArenaMemorySource<MemoryMapSource>>, NonZeroUsize) -> Result<GTACSA::CoroutineLocalAllocator, AllocErr>>(
coroutine_memory_source: &CoroutineMemorySource<GTACSA, CoroutineLocalAllocatorConstructor>,
start_arguments: Self::StartArguments
) -> Result<StartOutcome<GTACSA, Self>, AllocErr>
coroutine_memory_source: &CoroutineMemorySource<GTACSA, CoroutineLocalAllocatorConstructor>,
start_arguments: Self::StartArguments
) -> Result<StartOutcome<GTACSA, Self>, AllocErr>
Starts the coroutine; execution will transfer to the coroutine.
Execution does not start (returns Err(AllocErr)
) if there is not memory available to start the coroutine.
Ownership of start_arguments
will also transfer.
Returns the data transferred to us after the start and a guard object to resume the coroutine again or the final result.
If the coroutine panicked, this panics.