IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo struct

ProducerStage

struct ProducerStage[pipeline_origin: MutOrigin, num_stages: Int]

Unified handle for producing to a pipeline stage.

Works as both a linear type (direct use) and within context managers.

Lifecycle:

  1. Created via pipeline.acquire_producer() or context manager
  2. Use index() and mbar() for production
  3. Must call release() to advance stage (compiler-enforced)

Parameters​

  • ​pipeline_origin (MutOrigin): Origin of the pipeline reference.
  • ​num_stages (Int): Number of pipeline stages.

Fields​

  • ​pipeline (Pointer[ProducerConsumerPipeline[num_stages], pipeline_origin]):

Implemented traits​

AnyType, Movable

Methods​

__init__​

__init__(out self, pipeline: Pointer[ProducerConsumerPipeline[num_stages], pipeline_origin], index: UInt32, mbar: UnsafePointer[SharedMemBarrier, MutAnyOrigin, address_space=AddressSpace.SHARED])

index​

index(self) -> UInt32

Get the current stage index.

Returns:

UInt32

mbar​

mbar(self) -> MbarPtr

Get the barrier to signal when production is complete.

Caller is responsible for signaling via mma_arrive or similar.

Returns:

MbarPtr

release​

release(deinit self)

Advance producer to next stage.

This is the only way to destroy this linear type. The compiler will error if you don't call this.