Class SingleThreadedRefTracker

Inheritance Relationships

Base Type

Class Documentation

class wrench::SingleThreadedRefTracker : public wrench::RefTracker<SingleThreadedRefTracker>

This type implements a reference tracker which is not thread safe and is designed for single threaded use. It can be embedded inside a class for intrusive reference tracking.

This implements the RefTracker interface.

Public Types

using Counter = size_t

Defines the type of the counter.

Public Functions

auto add_reference_impl () noexcept -> void

Adds a reference to the count.

auto release_impl () noexcept -> bool

Decrements the referene count, returning true if the count is zero, and the resource can be released.

template<typename T, typename Deleter> auto destroy_resource_impl (T *resource, Deleter &&deleter) noexcept -> void

Destroys the resource resource, using the deleter, which should have a signature of:

auto destructor = [] (auto* resource) -> void {
// free(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.