Skip to main content
Log in

Mojo struct

RaisingCoroutine

@register_passable struct RaisingCoroutine[type: AnyType, origins: origin.set]

Represents a coroutine that can raise.

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 (origin.set): The origin set of the coroutine's captures.

Implemented traits

UnknownDestructibility

Methods

__init__

@implicit __init__(out self, handle: !co.routine)

Construct a coroutine object from a handle.

Args:

  • handle (!co.routine): The init handle.

__await__

__await__(owned self) -> type

Suspends the current coroutine until the coroutine is complete.

Returns:

The coroutine promise.

force_destroy

force_destroy(owned self)

Destroy the coroutine object.