the CComObjectRootEx
来源:互联网 发布:淘宝网制作费用 编辑:程序博客网 时间:2024/05/29 17:48
template <class ThreadModel>
class CComObjectRootEx : public CComObjectRootBase
{
public:
typedef ThreadModel _ThreadModel;
typedef typename _ThreadModel::AutoCriticalSection _CritSec;
typedef typename _ThreadModel::AutoDeleteCriticalSection _AutoDelCritSec;
typedef CComObjectLockT<_ThreadModel> ObjectLock;
~CComObjectRootEx() {}
ULONG InternalAddRef()
{
ATLASSUME(m_dwRef != -1L);
return _ThreadModel::Increment(&m_dwRef);
}
ULONG InternalRelease()
{
#ifdef _DEBUG
LONG nRef = _ThreadModel::Decrement(&m_dwRef);
if (nRef < -(LONG_MAX / 2))
{
ATLASSERT(0 && _T("Release called on a pointer that has already been released"));
}
return nRef;
#else
return _ThreadModel::Decrement(&m_dwRef);
#endif
}
HRESULT _AtlInitialConstruct()
{
return m_critsec.Init();
}
void Lock() {m_critsec.Lock();}
void Unlock() {m_critsec.Unlock();}
private:
_AutoDelCritSec m_critsec;
};
CComObjectRootEx handles object reference count management for both nonaggregated and aggregated objects. It holds the object reference count if your object is not being aggregated, and holds the pointer to the outer unknown if your object is being aggregated. For aggregated objects, CComObjectRootEx methods can be used to handle the failure of the inner object to construct, and to protect the outer object from deletion when inner interfaces are released or the inner object is deleted.
CComObjectRootex处理对象引用计数管理:无聚合与聚合。非聚合:保存对象引用计数;聚合:保存外部unknown的指针。对应聚合对象来说,CComOBjectRooex方法被用来处理内部对象的错误来创建并保护不被外部对象删除,当内部接口被释放或内部对象被删除时。
- the CComObjectRootEx
- CComObjectRootEx类
- CComObjectRootEx类 .
- The hell--The hope
- the Denser the Better ?
- the CComSingleThreadModel & the CComMultiThreadModel
- The more, The Better
- the+比较级,the+比较级
- The more, The Better
- The more, The Better
- the good,the bad ,the ugly
- The First!
- The Beginning
- The matrix
- The Singer
- The Makefile
- The thief
- The scrolls
- 2011-8-6
- 2011.08.06
- java中的集合类 以及 迭代器
- 表达式左值右值(C++学习)
- 刚刚CSDN号发现密码被改了 ...幸好找回来了。。
- the CComObjectRootEx
- poj1269
- tiny6410 Linux启动信息
- Phyx3@CGDC4
- 【教程】Gentoo的安装
- linux 内核中的锁机制--RCU
- android2.2
- 处理身份证相同的情况 2
- the CComSingleThreadModel & the CComMultiThreadModel