libtcspc.RecyclingBucketSource

class libtcspc.RecyclingBucketSource(object_type, *, blocking=False, clear_recycled=False, max_bucket_count=None)[source]

Bases: BucketSource

Bucket source that reuses storage from destroyed buckets.

Storage allocated for a bucket is returned to an internal pool when the bucket is destroyed and may be reused for a subsequent request, avoiding repeated allocation.

Parameters:
  • object_type (EventType) – Element type of the buckets produced by this source.

  • blocking (bool, keyword-only) – Behavior when max_bucket_count outstanding buckets exist and a new one is requested. True blocks until a bucket is recycled; False (the default) raises an overflow error.

  • clear_recycled (bool, keyword-only) – If True, recycled storage is cleared before reuse. Default False.

  • max_bucket_count (int or Param[int] or None, keyword-only) – Maximum number of outstanding buckets. None (the default) is unlimited. Must be non-negative.

Raises:

ValueError – If max_bucket_count is a negative integer, or a Param whose default_value is negative.

Notes

Thread-safe. When max_bucket_count is set, at least two buckets must be allowed to circulate to avoid deadlock.

See also

tcspc::recycling_bucket_source

The underlying C++ bucket source.

NewDeleteBucketSource

Bucket source without recycling.