libtcspc.Buffer

final class libtcspc.Buffer(event_type, threshold, access_tag)[source]

Bases: Node

Processor that buffers a single event type for emission on another thread.

A buffer splits the processing graph into a producer half (the processors upstream of this node) and a consumer half (the processors downstream). Events of event_type are enqueued by the producer thread (the one driving ExecutionContext.handle / ExecutionContext.flush) and are drained and re-emitted unchanged on a separate pump thread that the application runs via BufferAccessor.pump. The buffer thus decouples upstream and downstream processing and lets them run concurrently.

A heterogeneous event stream can be buffered by composing with Multiplex and Demultiplex so that a single VariantEvent type crosses the buffer.

Parameters:
  • event_type (EventType) – The event type to buffer. The input event set must consist only of this type.

  • threshold (int or Param[int]) – Number of events to accumulate before they are made available to the pump thread.

  • access_tag (AccessTag) – Tag used to retrieve a BufferAccessor from the ExecutionContext at runtime; the application uses it to drive the pump thread.

Notes

Events handled:

  • Events matching event_type: buffered and re-emitted unchanged on the pump thread.

  • All other event types: rejected at graph build time.

  • End of input: drained, then passed through on the pump thread.

ExecutionContext.flush returns once the producer half is flushed; it does not wait for the consumer half to drain. See BufferAccessor for the threading contract.

See also

tcspc::buffer()

The underlying C++ factory function.

BufferAccessor

Runtime accessor providing pump() and halt().