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

ConsumerStage

struct ConsumerStage[pipeline_origin: MutOrigin, num_stages: Int]

Unified handle for consuming from a pipeline stage.

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

Lifecycle:

  1. Created via pipeline.acquire_consumer() or context manager
  2. Use index() for consumption
  3. Must call release() to signal and advance (compiler-enforced)

Two exit paths:

  • release(): Signal consumption complete + advance (normal path)
  • release_without_signal(): Advance only (for explicit signaling)

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 for manual signaling.

Use this for specialized signaling patterns like umma_arrive_leader_cta. For standard usage, just call release().

Returns:

MbarPtr

arrive​

arrive(self)

Manually arrive on the consumer barrier.

Use for lane-guarded patterns: if lane_id() < CLUSTER_SIZE: stage.arrive() stage^.release_without_signal()

release​

release(deinit self)

Signal consumption complete and advance to next stage.

This is the standard exit path. Equivalent to: arrive() consumer_step()

release_without_signal​

release_without_signal(deinit self)

Advance to next stage WITHOUT signaling.

Use when you've already signaled via arrive() or specialized APIs.