IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /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. /get-started.md).

Mojo struct

ProduceContext

struct ProduceContext[pipeline_origin: MutOrigin, num_stages: Int, Backend: PipelineBackend = NvidiaMbarBackend[num_stages]]

Context manager for producing one pipeline stage.

  • enter: Waits for consumer to be ready, returns ref to stage
  • exit: Releases the stage (advances producer)

Note: The actual production signal (mma_arrive) is kernel-specific and must be called by the user before exiting the context.

Parameters

  • pipeline_origin (MutOrigin): Origin of the pipeline reference.
  • num_stages (Int): Number of pipeline stages.
  • Backend (PipelineBackend): Pipeline synchronization backend (defaults to NvidiaMbarBackend).

Fields

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

Implemented traits

AnyType, Deinitable, Movable

Methods

__init__

def __init__(out self, pipeline: Pointer[ProducerConsumerPipeline[num_stages, Backend], pipeline_origin])

__deinit__

def __deinit__(deinit self)

__enter__

def __enter__(mut self) -> ref[self._stage._value] ProducerStage[pipeline_origin, num_stages, Backend]

Wait for consumer and return reference to stage.

Returns:

ref[self._stage._value] ProducerStage[pipeline_origin, num_stages, Backend]

__exit__

def __exit__(mut self)

Release the stage (advances producer).