Template Class RefTracker¶
Defined in File ref_tracker.hpp
Class Documentation¶
-
template<typename
Impl
>
classwrench
::
RefTracker
¶ Forward declaration of reference tracking interface.
The
RefTracker class defines an interface for reference counting, which can be specialized for different contexts, and which allows the type requiring tracking to clean up the resource as well.- Template Parameters
Impl
: The implementation of the interface.
- Template Parameters
Impl
: The implementation of the interface.
Public Functions
-
auto add_reference () noexcept -> void
Adds a reference to the count.
-
auto release () noexcept -> bool
Decrements the referene count, returning true if the count is zero, and the resource can be released. If this returns true, then the resource should be destroyed through a call to
destroy()
.
-
template<typename T, typename Deleter> auto destroy_resource (T *resource, Deleter &&deleter) noexcept -> void
Destroys the resource
resource
, using thedeleter
, which should have a signature of:auto deleter = [] (auto* resource) -> void { // delete the resource }
- Parameters
resource
: The resource to destroy.deleter
: The deleter for the resource.
- Template Parameters
T
: The type of the resource.Deleter
: The type of the deleter.