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_;
88template <
class T,
class Deleter = RefObjectDeleter>
89class 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)
144template <
typename T,
typename... types>
151 return agora_refptr<T>(
new RefCountedObject<T>());
153template <
typename T,
typename P0>
static int Increment(volatile int *i)
Definition AgoraAtomicOps.h:27
static int AcquireLoad(volatile const int *i)
Definition AgoraAtomicOps.h:33
static int Decrement(volatile int *i)
Definition AgoraAtomicOps.h:30
Definition AgoraRefCountedObject.h:71
virtual agora::RefCountReleaseStatus Release() const
Definition AgoraRefCountedObjectInternal.h:113
RefCountedObject(P0 &&p0, P1 &&p1, Args &&... args)
Definition AgoraRefCountedObjectInternal.h:104
virtual bool HasOneRef() const
Definition AgoraRefCountedObjectInternal.h:129
agora::RefCounter ref_count_
Definition AgoraRefCountedObject.h:119
friend Deleter
Definition AgoraRefCountedObjectInternal.h:91
Deleter deleter_
Definition AgoraRefCountedObjectInternal.h:139
RefCountedObject(P0 &&p0)
Definition AgoraRefCountedObjectInternal.h:97
virtual ~RefCountedObject()
Definition AgoraRefCountedObjectInternal.h:132
virtual void AddRef() const
Definition AgoraRefCountedObjectInternal.h:111
RefCountedObject(const P0 &p0)
Definition AgoraRefCountedObjectInternal.h:99
RefCountedObject()
Definition AgoraRefCountedObjectInternal.h:93
Definition AgoraRefCountedObject.h:30
RefCounter(int ref_count)
Definition AgoraRefCountedObjectInternal.h:50
void IncRef()
Definition AgoraRefCountedObjectInternal.h:52
bool HasOneRef() const
Definition AgoraRefCountedObjectInternal.h:72
agora::RefCountReleaseStatus DecRef()
Definition AgoraRefCountedObjectInternal.h:58
Definition AgoraRefCountedObjectInternal.h:33
void operator()(const T *p) const
Definition AgoraRefCountedObjectInternal.h:36
Definition AgoraRefPtr.h:44
Definition AgoraAtomicOps.h:21
agora_refptr< T > make_refptr()
Definition AgoraRefCountedObject.h:129
OPTIONAL_ENUM_CLASS RefCountReleaseStatus
Definition AgoraRefPtr.h:25
Definition AgoraOptional.h:881