FastLED 3.9.3
Loading...
Searching...
No Matches
ref.cpp
1#include "ref.h"
2
3#include "namespace.h"
4
5FASTLED_NAMESPACE_BEGIN
6
7Referent::Referent() : mRefCount(0) {}
8Referent::~Referent() = default;
9void Referent::ref() { mRefCount++; }
10
11int Referent::ref_count() const { return mRefCount; }
12
13void Referent::unref() {
14 if (--mRefCount == 0) {
15 if (mWeakRef) {
16 mWeakRef->setReferent(nullptr);
17 mWeakRef.reset();
18 }
19 destroy();
20 }
21}
22
23void Referent::destroy() { delete this; }
24
25Referent::Referent(const Referent &) = default;
26Referent &Referent::operator=(const Referent &) = default;
27Referent::Referent(Referent &&) = default;
28Referent &Referent::operator=(Referent &&) = default;
29
30FASTLED_NAMESPACE_END