博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C++之Android弱指针
阅读量:2384 次
发布时间:2019-05-10

本文共 2691 字,大约阅读时间需要 8 分钟。

RefBase

在头文件RefBase.h中实现RefBase类。

class RefBase                                                                      {                                                                                  public:    ..........    class weakref_type                                                              {                                                                               public:                                                                             RefBase*            refBase() const;                                            void                incWeak(const void* id);                                    void                decWeak(const void* id);                                                                                                                                // acquires a strong reference if there is already one.                         bool                attemptIncStrong(const void* id);                           // acquires a weak reference if there is already one.                           // This is not always safe. see ProcessState.cpp and BpBinder.cpp               // for proper use.                                                              bool                attemptIncWeak(const void* id);                             //! DEBUGGING ONLY: Get current weak ref count.                                 int32_t             getWeakCount() const;                                       //! DEBUGGING ONLY: Print references held on object.                            void                printRefs() const;          };                    weakref_type*   createWeak(const void* id) const;                               weakref_type*   getWeakRefs() const;              protected:                                                                                                  RefBase();                                              virtual                 ~RefBase(); private:         class weakref_impl; private:          weakref_impl* const mRefs;  }

可以看出在RefBase类中,有两个内部类weakref_type和weakref_impl。

类weakref_type中封装了函数。

类weakref_impl,继承了weakref_type,还增加了mWeak变量。

weakref_impl类

在RefBase.cpp中实现weakref_impl类。

class RefBase::weakref_impl : public RefBase::weakref_type                         {                                                                                  public:                                                                                volatile int32_t    mStrong;                                                       volatile int32_t    mWeak;                                                         RefBase* const      mBase;                                                         volatile int32_t    mFlags;

转载地址:http://pafab.baihongyu.com/

你可能感兴趣的文章
C++程序员常用工具集
查看>>
在CSDN博客中添加量子恒道统计功能的做法
查看>>
C++调用IDL程序的做法(一)
查看>>
外部修改应用程序图标的做法
查看>>
database disk image is malformed解决方法
查看>>
有关error PRJ0003错误的思考
查看>>
实现自定义对话框程序快捷键的两种方法
查看>>
如何对抗微软霸权,google给我们上了一课
查看>>
未能将基于用户的Visual C++项目设置保存到user文件错误的解决
查看>>
获取windows版本信息的做法
查看>>
忆父亲
查看>>
png库结合zlib库使用出现的一个链接问题的解决
查看>>
STL数组和com数组相互转换的做法
查看>>
开发平台软件中关于第三方库管理的一些思考
查看>>
svn创建分支的做法
查看>>
“当前不会命中断点。源代码与原始版本不同”的问题的有效解决办法
查看>>
对面向对象和面向过程的一些新理解
查看>>
软件开发中的资源管理
查看>>
有关博客的一些断想
查看>>
Windows Server2008上安装VS2008出错及解决办法
查看>>