libtcspc C++ API
Streaming TCSPC and time tag data processing
Loading...
Searching...
No Matches
tcspc::bucket_source< T > Struct Template Referenceabstract

Description

template<typename T>
struct tcspc::bucket_source< T >

Abstract base class for polymorphic bucket sources.

Bucket source instances are handled via std::shared_ptr.

See also
Bucket sources
Template Parameters
Tthe bucket data element type

Inherited by tcspc::new_delete_bucket_source< T >, tcspc::recycling_bucket_source< T, Blocking, ClearRecycled >, tcspc::sharable_new_delete_bucket_source< T >, tcspc::sharable_recycling_bucket_source< T, Blocking, ClearRecycled >, and tcspc::test_bucket_source< T >.

Public Member Functions

virtual auto bucket_of_size (std::size_t size) -> bucket< T >=0
 Create a bucket of size elements of type 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.

Member Function Documentation

◆ bucket_of_size()

template<typename T>
virtual auto tcspc::bucket_source< T >::bucket_of_size ( std::size_t size) -> bucket< T >
pure virtual

Create a bucket of size elements of type T.

Attention
Processors that use a bucket source must not create any buckets during construction. Buckets should be created while handling events (or flush) only. This is because we support use cases in which the bucket source is fully configured only after the processing graph has been built.

Implemented in tcspc::new_delete_bucket_source< T >, tcspc::recycling_bucket_source< T, Blocking, ClearRecycled >, tcspc::sharable_new_delete_bucket_source< T >, tcspc::sharable_recycling_bucket_source< T, Blocking, ClearRecycled >, and tcspc::test_bucket_source< T >.

◆ shared_view_of()

template<typename T>
virtual auto tcspc::bucket_source< T >::shared_view_of ( bucket< T > const & bkt) -> bucket< T const >
inlinenodiscardvirtual

Create a shared view bucket that is a read-only view of the given bucket but may outlive the original bucket.

Note
This function is only available for sharable bucket sources (see supports_shared_views()). The default implementation throws std::logic_error.

When supported, this function creates a second bucket that shares ownership of the underlying storage of the given bkt. A shared view remains valid even if the original bucket is destroyed first.

For this reason, it is safe to pass a shared view bucket by non-const (rvalue) reference to other code, such as a downstream processor. This allows move-semantic transmission of the shared view bucket, allowing for, e.g., buffering without copying of the data.

Shared views may only be created from original non-view buckets; they cannot be created from existing shared views.

Depending on the bucket source, storage extraction from a shared view bucket may or may not be supported (even if the original buckets support it).

Sharability is an optional feature of bucket sources because managing shared storage may have overhead.

Parameters
bktthe original bucket, which must have been returned by bucket_of_size() of this bucket source (and not by a previous call to shared_view_of()).
Returns
A shared view bucket.

Reimplemented in tcspc::sharable_new_delete_bucket_source< T >, tcspc::sharable_recycling_bucket_source< T, Blocking, ClearRecycled >, and tcspc::test_bucket_source< T >.

◆ supports_shared_views()

template<typename T>
virtual auto tcspc::bucket_source< T >::supports_shared_views ( ) const -> bool
inlinenodiscardvirtualnoexcept

Return whether this bucket source is a sharable bucket source.

A sharable bucket source supports the creation of shared views of buckets via shared_view_of().

Note
This function is overridden to return true for sharable bucket sources. The default implementation returns false.

Reimplemented in tcspc::sharable_new_delete_bucket_source< T >, tcspc::sharable_recycling_bucket_source< T, Blocking, ClearRecycled >, and tcspc::test_bucket_source< T >.


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