Agora C++ API Reference for All Platforms
|
10 #include "AgoraRefPtr.h"
11 #include "api2/AgoraAtomicOps.h"
12 #include <api/aosl_mpq.h>
13 #include <api/cpp/aosl_ref_class.h>
15 #ifndef __AGORA_REF_COUNTED_OBJECT_INTERNAL_H__
16 #define __AGORA_REF_COUNTED_OBJECT_INTERNAL_H__
19 #if defined(__AGORA_REF_COUNTED_OBJECT_H__)
20 #error AgoraRefCountedObject is deprected now, its only purpose is for API compatiable. Consider using <api2/internal/AgoraRefCountedObjectInternal.h> instead.
23 #ifndef OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER
24 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
25 #define OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER agora::RefCountReleaseStatus::
27 #define OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER
37 if(aosl_ref_class::run(aosl_mpq_main(), AOSL_REF_INVALID, __FUNCTION__, [p](
const aosl_ts_t &queued_ts, aosl_refobj_t robj){
50 explicit RefCounter(
int ref_count) : ref_count_(ref_count) {}
60 ? OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER kDroppedLastRef
61 : OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER kOtherRefsRemained);
78 volatile int ref_count_;
88 template <
class T,
class Deleter = RefObjectDeleter>
89 class RefCountedObject :
public T {
96 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
102 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
103 template <
class P0,
class P1,
class... Args>
105 : T(
std::forward<P0>(p0),
106 std::forward<P1>(p1),
107 std::forward<Args>(args)...),
115 if (status == OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER kDroppedLastRef) {
143 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
144 template <
typename T,
typename... types>
149 template <
typename T>
151 return agora_refptr<T>(
new RefCountedObject<T>());
153 template <
typename T,
typename P0>
155 return agora_refptr<T>(
new RefCountedObject<T>(p0));
virtual agora::RefCountReleaseStatus Release() const
Definition: AgoraRefCountedObjectInternal.h:113
static int AcquireLoad(volatile const int *i)
Definition: AgoraAtomicOps.h:33
RefCountedObject(P0 &&p0, P1 &&p1, Args &&... args)
Definition: AgoraRefCountedObjectInternal.h:104
Definition: AgoraRefPtr.h:44
agora_refptr< T > make_refptr(types &&... args)
Definition: AgoraRefCountedObject.h:124
static int Decrement(volatile int *i)
Definition: AgoraAtomicOps.h:30
virtual bool HasOneRef() const
Definition: AgoraRefCountedObjectInternal.h:129
Definition: AgoraRefCountedObjectInternal.h:33
agora::RefCounter ref_count_
Definition: AgoraRefCountedObject.h:119
RefCountedObject()
Definition: AgoraRefCountedObjectInternal.h:93
virtual void AddRef() const
Definition: AgoraRefCountedObjectInternal.h:111
Definition: AgoraRefCountedObject.h:71
Definition: AgoraAtomicOps.h:21
static int Increment(volatile int *i)
Definition: AgoraAtomicOps.h:27
void operator()(const T *p) const
Definition: AgoraRefCountedObjectInternal.h:36
RefCountedObject(const P0 &p0)
Definition: AgoraRefCountedObjectInternal.h:99
RefCountedObject(P0 &&p0)
Definition: AgoraRefCountedObjectInternal.h:97
void IncRef()
Definition: AgoraRefCountedObjectInternal.h:52
Deleter deleter_
Definition: AgoraRefCountedObjectInternal.h:139
bool HasOneRef() const
Definition: AgoraRefCountedObjectInternal.h:72
Definition: AgoraOptional.h:881
virtual ~RefCountedObject()
Definition: AgoraRefCountedObjectInternal.h:132
Definition: AgoraRefCountedObject.h:30
OPTIONAL_ENUM_CLASS RefCountReleaseStatus
Definition: AgoraRefPtr.h:25
friend Deleter
Definition: AgoraRefCountedObjectInternal.h:91
agora::RefCountReleaseStatus DecRef()
Definition: AgoraRefCountedObjectInternal.h:58
RefCounter(int ref_count)
Definition: AgoraRefCountedObjectInternal.h:50