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:
- Created via
pipeline.acquire_producer()or context manager - Use
index()andmbar()for production - 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
comptime members
__moveinit__is_trivial
comptime __moveinit__is_trivial = False
Methods
__init__
__init__(out self, pipeline: Pointer[ProducerConsumerPipeline[num_stages], pipeline_origin], index: UInt32, mbar: LegacyUnsafePointer[SharedMemBarrier, address_space=AddressSpace.SHARED])
__moveinit__
__moveinit__(out self, deinit other: Self)
Move constructor for Optional support.
index
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.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!