A producer is a queue client that feeds values into a disruptor queue. The queue manages the allocation of memory for value instances in the queue, however, so the produces “claims” the next free value instance in the queue. Once claimed, the producer copies or fills in the value instance and “publishes” the value instances, making it available for consumer clients. At the point of publishing the value instance availability, the producer relinquishes its claim to the value instance. The value instance is then considered active and available until all consumer clients inform the disruptor queue they are finished with the value instance. At this point, the disruptor queue makes the value instance’s slot in the queue array available for reuse and claim by a producer.
A Varon-T producer client must implement the following interface:
The index of this producer client within queue.
The ID of the last value instance returned by the producer.
The ID of the last value instance in the distruptor queue currently claimed by the producer.
This is the function the producer will call to claim a value instance in the disruptor queue. The function blocks until there is a value to return to the producer. If the queue is currently full, then this function will call the producers’s yield method to permit other producers and consumer clients execution time.
This is the function the producer will use to publish a value instance ID to the disruptor queue.
The number of value instances in a disruptor queue the producers will claim in a single call to claim.
A pointer to the function implementing the producer’s yield strategy.
A name for the producer.
The number of batch value instances the producer has fed. Note that VRT_QUEUE_STATS must be defined as true.
The number of times the producer has yield whilst waiting to claim a value instances. Note that VRT_QUEUE_STATS must be defined as true.
We provide the following built-in producer operations:
Allocate a new producer instance to feed the given queue q and initialize to claim batch_size values at a time. If batch_size is set to 0, then a reasonable default batch size is calculated.
Free a producer instance and any associated resources.
Claim the next available value instance managed by the producer’s queue. If this funtion returns no error (0), then a value instance is loaded into value and the caller has complete control over its contents.
Publish the most recently claimed value. This function will no return until the value is successfully published to the queue’s consumers. Immediately upon return, the relinquishes all rights to the claimed value, including for reading values. The queue has complete control and can overwrite the value’s contents at any time.
Signal that this producer will no longer produce any new values for its queue.
Signals that this producer is flushing any claimed values back to the queue.