libtcspc.BufferAccessor

class libtcspc.BufferAccessor(*args, **kwargs)[source]

Bases: Accessor, Protocol

Run-time accessor for a Buffer or RealTimeBuffer processor.

A buffer splits the processing graph into a producer half (the processors upstream of the buffer, driven by ExecutionContext.handle / ExecutionContext.flush) and a consumer half (the processors downstream of the buffer). Events enqueued by the producer are drained and emitted on a separate pump thread that the application must run by calling pump.

Because of this, ExecutionContext.flush returns as soon as the producer half is flushed; it does not wait for the consumer half to drain. Processing is complete only when the pump thread (the pump call) has returned. The application is responsible for spawning and joining the pump thread, for catching the exception that pump may raise, and for keeping the ExecutionContext alive until the pump thread has finished (the accessor holds a raw pointer into the processor).

See also

tcspc::buffer_accessor

The underlying C++ accessor.

Buffer

The processor accessed.

RealTimeBuffer

The processor accessed.

halt()[source]

Signal that the producer stopped without flushing.

Causes a blocked or subsequent pump to raise SourceHalted rather than returning normally. Must be called if the source stops (e.g. on cancellation or a producer-side error) without flushing the producer half, so that the pump thread does not block forever. It is a harmless no-op if the buffer has already flushed or otherwise terminated.

Return type:

None

pump()[source]

Drain buffered events and emit them downstream on the calling thread.

This call blocks and must be made on a thread other than the one calling ExecutionContext.handle / ExecutionContext.flush. The GIL is released while it blocks and drains.

Returns:

Returns normally when the producer half flushes and the queue drains.

Return type:

None

Raises: