Chromium Embedded Framework (CEF)  130.1.2+g48f3ef6+chromium-130.0.6723.44
base::RefCounted< T, Traits > Class Template Reference

A base class for reference counted classes. More...

#include "include/base/cef_ref_counted.h"

Inheritance diagram for base::RefCounted< T, Traits >:

Public Member Functions

 RefCounted ()
 
 RefCounted (const RefCounted &)=delete
 
RefCountedoperator= (const RefCounted &)=delete
 
void AddRef () const
 
void Release () const
 

Static Public Attributes

static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference
 

Protected Member Functions

 ~RefCounted ()=default
 

Friends

struct DefaultRefCountedTraits< T >
 

Detailed Description

template<class T, typename Traits = DefaultRefCountedTraits<T>>
class base::RefCounted< T, Traits >

A base class for reference counted classes.

Otherwise, known as a cheap knock-off of WebKit's RefCounted<T> class. To use this, just extend your class from it like so:

  class MyFoo : public base::RefCounted<MyFoo> {
   ...
   private:
    friend class base::RefCounted<MyFoo>;
    ~MyFoo();
  };

Usage Notes:

  1. You should always make your destructor non-public, to avoid any code deleting the object accidentally while there are references to it.
  2. You should always make the ref-counted base class a friend of your class, so that it can access the destructor.

The ref count manipulation to RefCounted is NOT thread safe and has DCHECKs to trap unsafe cross thread usage. A subclass instance of RefCounted can be passed to another execution thread only when its ref count is 1. If the ref count is more than 1, the RefCounted class verifies the ref updates are made on the same execution thread as the previous ones. The subclass can also manually call IsOnValidThread to trap other non-thread-safe accesses; see the documentation for that method.

Constructor & Destructor Documentation

◆ RefCounted() [1/2]

template<class T , typename Traits = DefaultRefCountedTraits<T>>
base::RefCounted< T, Traits >::RefCounted ( )
inline

◆ RefCounted() [2/2]

template<class T , typename Traits = DefaultRefCountedTraits<T>>
base::RefCounted< T, Traits >::RefCounted ( const RefCounted< T, Traits > &  )
delete

◆ ~RefCounted()

template<class T , typename Traits = DefaultRefCountedTraits<T>>
base::RefCounted< T, Traits >::~RefCounted ( )
protecteddefault

Member Function Documentation

◆ AddRef()

template<class T , typename Traits = DefaultRefCountedTraits<T>>
void base::RefCounted< T, Traits >::AddRef ( ) const
inline

◆ operator=()

template<class T , typename Traits = DefaultRefCountedTraits<T>>
RefCounted& base::RefCounted< T, Traits >::operator= ( const RefCounted< T, Traits > &  )
delete

◆ Release()

template<class T , typename Traits = DefaultRefCountedTraits<T>>
void base::RefCounted< T, Traits >::Release ( ) const
inline

Friends And Related Function Documentation

◆ DefaultRefCountedTraits< T >

template<class T , typename Traits = DefaultRefCountedTraits<T>>
friend struct DefaultRefCountedTraits< T >
friend

Member Data Documentation

◆ kRefCountPreference

template<class T , typename Traits = DefaultRefCountedTraits<T>>
constexpr cef_subtle::StartRefCountFromZeroTag base::RefCounted< T, Traits >::kRefCountPreference
staticconstexpr
Initial value:
=
cef_subtle::kStartRefCountFromZeroTag

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