Repository navigation
ref_counter
Dmitry Koplyarov edited this page May 17, 2016
·
4 revisions
A policy that defines the reference counting mechanism.
namespace ref_counter
{
struct atomic;
struct single_threaded;
}
A ref_counter that uses std::atomic as a counter value. A good default.
A ref_counter that uses int as a counter value. This is faster than atomic, but is not thread-safe. You may want to use it in single-threaded signals.
struct my_ref_counter
{
using tag = wigwag::ref_counter::tag<wigwag::api_version<2, 0>>;
my_ref_counter(int initVal);
int add_ref() const;
int release() const;
};using tag = wigwag::ref_counter::tag<wigwag::api_version<2, 0>>;The policy tag. Must be a type alias for wigwag::ref_counter::tag<wigwag::api_version<2, 0>>.
my_ref_counter(int initVal);Arguments:
- initVal - initial reference counter value
int add_ref() const;This method should increase reference counter.
Return value: the new reference counter value
int release() const;This method should decrease reference counter.
Return value: the new reference counter value