Flutter Engine
The Flutter Engine
Public Member Functions | Friends | List of all members
dart::bin::ReferenceCounted< Derived > Class Template Reference

#include <reference_counting.h>

Public Member Functions

 ReferenceCounted ()
 
virtual ~ReferenceCounted ()
 
void Retain ()
 
void Release ()
 

Friends

class RefCntReleaseScope< Derived >
 

Detailed Description

template<class Derived>
class dart::bin::ReferenceCounted< Derived >

Definition at line 36 of file reference_counting.h.

Constructor & Destructor Documentation

◆ ReferenceCounted()

template<class Derived >
dart::bin::ReferenceCounted< Derived >::ReferenceCounted ( )
inline

Definition at line 38 of file reference_counting.h.

38 : ref_count_(1) {
39#if defined(DEBUG)
40 instances_.fetch_add(1u, std::memory_order_relaxed);
41#endif // defined(DEBUG)
42 }

◆ ~ReferenceCounted()

template<class Derived >
virtual dart::bin::ReferenceCounted< Derived >::~ReferenceCounted ( )
inlinevirtual

Definition at line 44 of file reference_counting.h.

44 {
45 ASSERT(ref_count_ == 0);
46#if defined(DEBUG)
47 instances_.fetch_sub(1u, std::memory_order_relaxed);
48#endif // defined(DEBUG)
49 }
#define ASSERT(E)

Member Function Documentation

◆ Release()

template<class Derived >
void dart::bin::ReferenceCounted< Derived >::Release ( )
inline

Definition at line 56 of file reference_counting.h.

56 {
57 intptr_t old = ref_count_.fetch_sub(1u, std::memory_order_acq_rel);
58 ASSERT(old > 0);
59 if (old == 1) {
60 delete static_cast<Derived*>(this);
61 }
62 }

◆ Retain()

template<class Derived >
void dart::bin::ReferenceCounted< Derived >::Retain ( )
inline

Definition at line 51 of file reference_counting.h.

51 {
52 intptr_t old = ref_count_.fetch_add(1u, std::memory_order_relaxed);
53 ASSERT(old > 0);
54 }

Friends And Related Function Documentation

◆ RefCntReleaseScope< Derived >

template<class Derived >
friend class RefCntReleaseScope< Derived >
friend

Definition at line 78 of file reference_counting.h.


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