Mojo struct
Coroutine
@register_passable
struct Coroutine[type: AnyType, origins: OriginSet]
Represents a coroutine.
Coroutines can pause execution saving the state of the program (including values of local variables and the location of the next instruction to be executed). When the coroutine is resumed, execution continues from where it left off, with the saved state restored.
Parameters
- type (
AnyType
): Type of value returned upon completion of the coroutine. - origins (
OriginSet
): The origin of the coroutine's captures.
Implemented traits
AnyType
,
Movable
,
UnknownDestructibility
Aliases
__del__is_trivial
alias __del__is_trivial = True
__moveinit__is_trivial
alias __moveinit__is_trivial = True
Methods
__init__
@implicit
__init__(handle: !co.routine) -> Self
Construct a coroutine object from a handle.
Args:
- handle (
!co.routine
): The init handle.
__await__
__await__(var self, out result: type)
Suspends the current coroutine until the coroutine is complete.
Returns:
type
: The coroutine promise.
force_destroy
force_destroy(var self)
Destroy the coroutine object.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!