libtcspc.BufferAccessor¶
- class libtcspc.BufferAccessor(*args, **kwargs)[source]¶
-
Run-time accessor for a
BufferorRealTimeBufferprocessor.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 callingpump.Because of this,
ExecutionContext.flushreturns 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 (thepumpcall) has returned. The application is responsible for spawning and joining the pump thread, for catching the exception thatpumpmay raise, and for keeping theExecutionContextalive until the pump thread has finished (the accessor holds a raw pointer into the processor).See also
- tcspc::buffer_accessor
The underlying C++ accessor.
BufferThe processor accessed.
RealTimeBufferThe processor accessed.
- halt()[source]¶
Signal that the producer stopped without flushing.
Causes a blocked or subsequent
pumpto raiseSourceHaltedrather 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:
SourceHalted – If
haltwas called before the buffer received a flush from its producer half.EndOfProcessing – If a downstream sink terminated processing.
Exception – Any other exception raised by a downstream processor (e.g. a sink raising an error). After such a downstream termination, the producer thread’s next
ExecutionContext.handle/ExecutionContext.flushraisesEndOfProcessing.