libtcspc C++ API
Streaming TCSPC and time tag data processing
Loading...
Searching...
No Matches
tcspc::recycling_bucket_source< T, Blocking, ClearRecycled > Class Template Referencefinal

Description

template<typename T, bool Blocking = false, bool ClearRecycled = false>
class tcspc::recycling_bucket_source< T, Blocking, ClearRecycled >

Bucket source that reuses storage.

This bucket source provides buckets whose underlying memory is allocated via new[], but storage from destroyed buckets is reused for new buckets. Extraction of the storage is not supported (cannot be done because the storage is a private type).

This bucket source is thread-safe: buckets (or their storage) may be created and destroyed on multiple threads simultaneously. (Access to an individual bucket is not thread-safe.)

Template Parameters
Tthe bucket element type
Blockingif true, block when a new bucket is requested but the number of outstanding buckets has reached the maximum count.
ClearRecycledif true, bucket data elements will be destroyed when the bucket (or its storage) is destroyed; otherwise elements may remain in the recycled storage.

Inherits tcspc::bucket_source< T >, and std::enable_shared_from_this< recycling_bucket_source< T, false, false > >.

Public Member Functions

auto bucket_of_size (std::size_t size) -> bucket< T > override
 Implements bucket source requirement.
Public Member Functions inherited from tcspc::bucket_source< T >
virtual auto shared_view_of (bucket< T > const &bkt) -> bucket< T const >
 Create a shared view bucket that is a read-only view of the given bucket but may outlive the original bucket.
virtual auto supports_shared_views () const noexcept -> bool
 Return whether this bucket source is a sharable bucket source.

Static Public Member Functions

static auto create (arg::max_bucket_count<> max_bucket_count=arg::max_bucket_count{std::numeric_limits< std::size_t >::max()}, arg::max_recycled_size<> max_recycled_size=arg::max_recycled_size<>{ 0}) -> std::shared_ptr< bucket_source< T > >
 Create an instance.

Member Function Documentation

◆ bucket_of_size()

template<typename T, bool Blocking = false, bool ClearRecycled = false>
auto tcspc::recycling_bucket_source< T, Blocking, ClearRecycled >::bucket_of_size ( std::size_t size) -> bucket< T >
inlineoverridevirtual

Implements bucket source requirement.

This function will block if Blocking is true and the maximum bucket count has been reached. It will then unblock when an outstanding bucket is destroyed.

Exceptions
tcspc::buffer_overflow_errorif Blocking is false and the maximum bucket count has been reached.

Implements tcspc::bucket_source< T >.

◆ create()

template<typename T, bool Blocking = false, bool ClearRecycled = false>
auto tcspc::recycling_bucket_source< T, Blocking, ClearRecycled >::create ( arg::max_bucket_count<> max_bucket_count = arg::max_bucket_count{std::numeric_limits<std::size_t>::max()},
arg::max_recycled_size<> max_recycled_size = arg::max_recycled_size<>{ 0} ) -> std::shared_ptr< bucket_source< T > >
inlinestatic

Create an instance.

Parameters
max_bucket_countthe maximum number of buckets that can be outstanding from this bucket source at any given time.
max_recycled_sizethe maximum bucket size whose storage is recycled; if 0, recycle all

The documentation for this class was generated from the following file: