yate学习--yateclass.h--class YATE_API RefObject : public GenObject
来源:互联网 发布:诵读古兰经软件 编辑:程序博客网 时间:2024/04/28 12:50
请声明出处:
对象的引用计数的类,基本大部分的类都继承了该类:
/** * A reference counted object. * 引用计数的对象 * Whenever using multiple inheritance you should inherit this class virtually. * 使用多重继承,一般都会继承这个类 */class YATE_API RefObject : public GenObject{ YNOCOPY(RefObject); // no automatic copies pleasepublic: /** * The constructor initializes the reference counter to 1! * 构造函数,初始化引用计数器为1. * Use deref() to destruct the object when safe * 使用deref()去销毁这个对象在安全的时候 */ RefObject(); /** * Destructor. */ virtual ~RefObject(); /** * Get a pointer to a derived class given that class name * 获取一个指向派生类的指针,因为类名 * @param name Name of the class we are asking for * @参数 name,请求的类名 * @return Pointer to the requested class or NULL if this object doesn't implement it * @返回被请求类的地址,为NULL,如果这个对象没有实例化 */ virtual void* getObject(const String& name) const; /** * Check if the object is still referenced and safe to access. * 检查对象是否依旧被引用并且安全的访问 * Note that you should not trust this result unless the object is locked * 注意,不能完全相信这个结果,除非对象被其他方法锁定 * by other means. * @return True if the object is referenced and safe to access * @返回True,如果对象被引用并且安全的访问 */ virtual bool alive() const; /** * Increments the reference counter if not already zero * 增加引用计数器,如果不为0 * @return True if the object was successfully referenced and is safe to access * @返回True,如果对象被引用并且安全的访问 */ bool ref(); /** * Decrements the reference counter, destroys the object if it reaches zero * 减少引用计数器,如果为0则销毁对象 * <pre> * // Deref this object, return quickly if the object was deleted * if (deref()) return; * </pre> * @return True if the object may have been deleted, false if it still exists and is safe to access * @返回true,如果对象已经被删除,false,依旧存在并且安全的访问 */ bool deref(); /** * Get the current value of the reference counter * 获取引用计数器当前的值 * @return The value of the reference counter */ inline int refcount() const{ return m_refcount; } /** * Refcounted objects should just have the counter decremented. * 引用计数对象减少计数器 * That will destroy them only when the refcount reaches zero. * 当引用计数器为0的时候销毁 */ virtual void destruct(); /** * Check if reference counter manipulations are efficient on this platform. * 检查在这个平台上引用计数器对象是否有效 * If platform does not support atomic operations a mutex pool is used. * 如果该平台不支持原子操作使用互斥对象池 * @return True if refcount uses atomic integer operations * @返回true,如果对象计数使用原子整数操作 */ static bool efficientIncDec();protected: /** * This method is called when the reference count reaches zero after * 当该应用计数为0之后调用这个方法 * unlocking the mutex if the call to zeroRefsTest() returned true. * 如果调用zeroRefsTest() 返回true,解除这个互斥锁 * The default behaviour is to delete the object. * 默认删除这个对象 */ virtual void zeroRefs(); /** * Bring the object back alive by setting the reference counter to one. * Note that it works only if the counter was zero previously * @return True if the object was resurrected - its name may be Lazarus ;-) */ bool resurrect(); /** * Pre-destruction notification, called just before the object is deleted. * Unlike in the destructor it is safe to call virtual methods here. * Reimplementing this method allows to perform any object cleanups. */ virtual void destroyed();private: int m_refcount; Mutex* m_mutex;};
2 0
- yate学习--yateclass.h--class YATE_API RefObject : public GenObject
- yate学习--yateclass.h--class YATE_API ObjList : public GenObject
- yate学习--yateclass.h--class YATE_API SocketAddr : public GenObject
- yate学习--yateclass.h--class YATE_API GenObject
- yate学习--yatengine.h--class YATE_API MessageReceiver : public GenObject
- yate学习--yateclass.h--class YATE_API NamedString : public String
- yate学习--yateclass.h--class YATE_API NamedList : public String
- yate学习--yateclass.h--class YATE_API Thread : public Runnable
- yate学习--yateclass.h--class YATE_API NamedCounter : public String
- yate学习--yateclass.h--class YATE_API Socket : public Stream
- yate学习--yateclass.h--class YATE_API Runnable
- yate学习--yateclass.h--class YATE_API Stream
- yate学习--yateclass.h--class YATE_API DebugEnabler
- yate学习--yateclass.h--class YATE_API Lockable
- yate学习--yatesip.h--class YSIP_API SIPMessage : public RefObject
- yate学习--yatengine.h--class YATE_API Configuration : public String
- yate学习--yatesip.h--class YSIP_API SIPParty : public RefObjec
- yate学习--./yate/packingyate.logrotate
- 健康项目管理优秀实践及运用-讲师团俊平老师主讲
- BASE64编码and解码的C实现
- x264源代码简单分析:宏块分析(Analysis)部分-帧内宏块(Intra)
- GET 和 POST
- 写串口
- yate学习--yateclass.h--class YATE_API RefObject : public GenObject
- AWS中国区EC2 G2实例实测(Caffe+CUDA7+cuDNN)
- jQuery init 方法中的context详解
- 使用自己电脑搭建一个外网可以访问的服务器tomcat本地搭建
- xCode6制作动态及静态Framework
- 【Git】Git基本常用命令
- 鸡啄米vc++2010系列44(Ribbon界面开发:创建Ribbon样式的应用程序框架)
- const重载解析
- opengl离屏渲染(不需要和窗口绑定,仅当作一个可以渲染一张图片的API使用)+ opencv显示