nsCountedRef 编辑
nsCountedRef<T> is a template class implementing an object that takes a strong reference to a reference-counted resource that must be released, typically on destruction of the object.
nsCountedRef has a role similar to nsRefPtr but does not require that the handle is a pointer to an object that has AddRef() and Release() methods. nsCountedRef is therefore useful for managing references to foreign objects.
nsCountedRef<T> is derived from nsAutoRef<T> and so inherits its methods. nsCountedRef differs from nsAutoRef in that nsCountedRef constructors add a reference to the resource, and in that nsCountedRef provides copy construction< and assignment operators enabling more than one concurrent reference to the same resource.
In order to use nsCountedRef<T> for a class T associated with a particular resource type, the type of the handle to the resource and the methods for referencing and releasing the resource must be provided for class T. This is usually done by providing a specialization of nsAutoRefTraits<T>.
nsCountedRef<T> is defined in xpcom/base/nsAutoRef.h
.
See Also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论