x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
shared_count.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\interprocess\smart_ptr\detail\shared_count.hpp
旋转
特效
属性
历史版本
////////////////////////////////////////////////////////////////////////////// // // This file is the adaptation for Interprocess of boost/detail/shared_count.hpp // // (C) Copyright Peter Dimov and Multi Media Ltd. 2001, 2002, 2003 // (C) Copyright Peter Dimov 2004-2005 // (C) Copyright Ion Gaztanaga 2006-2008. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/interprocess for documentation. // ////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_INTERPROCESS_DETAIL_SHARED_COUNT_HPP_INCLUDED #define BOOST_INTERPROCESS_DETAIL_SHARED_COUNT_HPP_INCLUDED // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include
#include
#include
#include
#include
#include
#include
#include
// std::less namespace boost { namespace interprocess { namespace detail{ template
class weak_count; template
class shared_count { public: typedef typename detail::pointer_to_other
::type pointer; private: typedef sp_counted_impl_pd
counted_impl; typedef typename detail::pointer_to_other
::type counted_impl_ptr; typedef typename detail::pointer_to_other
::type counted_base_ptr; typedef typename VoidAllocator::template rebind
::other counted_impl_allocator; typedef typename detail::pointer_to_other
::type const_deleter_pointer; typedef typename detail::pointer_to_other
::type const_allocator_pointer; pointer m_px; counted_impl_ptr m_pi; template
friend class weak_count; template
friend class shared_count; public: shared_count() : m_px(0), m_pi(0) // nothrow {} template
shared_count(const Ptr &p, const VoidAllocator &a, Deleter d) : m_px(p), m_pi(0) { BOOST_TRY{ if(p){ counted_impl_allocator alloc(a); m_pi = alloc.allocate(1); //Anti-exception deallocator scoped_ptr
> deallocator(m_pi, alloc); //It's more correct to use VoidAllocator::construct but //this needs copy constructor and we don't like it new(detail::get_pointer(m_pi))counted_impl(p, a, d); deallocator.release(); } } BOOST_CATCH (...){ d(p); // delete p BOOST_RETHROW } BOOST_CATCH_END } ~shared_count() // nothrow { if( m_pi != 0 ) m_pi->release(); } shared_count(shared_count const & r) : m_px(r.m_px), m_pi(r.m_pi) // nothrow { if( m_pi != 0 ) m_pi->add_ref_copy(); } //this is a test template
explicit shared_count(shared_count
const & r) : m_px(r.m_px), m_pi(r.m_pi) // nothrow { if( m_pi != 0 ) m_pi->add_ref_copy(); } //this is a test template
explicit shared_count(const pointer & ptr, shared_count
const & r) : m_px(ptr), m_pi(r.m_pi) // nothrow { if( m_pi != 0 ) m_pi->add_ref_copy(); } /* explicit shared_count(weak_count
const & r) // throws bad_weak_ptr when r.use_count() == 0 : m_pi( r.m_pi ) { if( m_pi == 0 || !m_pi->add_ref_lock() ){ boost::throw_exception( boost::interprocess::bad_weak_ptr() ); } } */ template
explicit shared_count(weak_count
const & r) // throws bad_weak_ptr when r.use_count() == 0 : m_px(r.m_px), m_pi( r.m_pi ) { if( m_pi == 0 || !m_pi->add_ref_lock() ){ throw( boost::interprocess::bad_weak_ptr() ); } } const pointer &get_pointer() const { return m_px; } pointer &get_pointer() { return m_px; } shared_count & operator= (shared_count const & r) // nothrow { m_px = r.m_px; counted_impl_ptr tmp = r.m_pi; if( tmp != m_pi ){ if(tmp != 0) tmp->add_ref_copy(); if(m_pi != 0) m_pi->release(); m_pi = tmp; } return *this; } template
shared_count & operator= (shared_count
const & r) // nothrow { m_px = r.m_px; counted_impl_ptr tmp = r.m_pi; if( tmp != m_pi ){ if(tmp != 0) tmp->add_ref_copy(); if(m_pi != 0) m_pi->release(); m_pi = tmp; } return *this; } void swap(shared_count & r) // nothrow { detail::do_swap(m_px, r.m_px); detail::do_swap(m_pi, r.m_pi); } long use_count() const // nothrow { return m_pi != 0? m_pi->use_count(): 0; } bool unique() const // nothrow { return use_count() == 1; } const_deleter_pointer get_deleter() const { return m_pi ? m_pi->get_deleter() : 0; } // const_allocator_pointer get_allocator() const // { return m_pi ? m_pi->get_allocator() : 0; } template
bool internal_equal (shared_count
const & other) const { return this->m_pi == other.m_pi; } template
bool internal_less (shared_count
const & other) const { return std::less
()(this->m_pi, other.m_pi); } }; template
inline bool operator==(shared_count
const & a, shared_count
const & b) { return a.internal_equal(b); } template
inline bool operator<(shared_count
const & a, shared_count
const & b) { return a.internal_less(b); } template
class weak_count { public: typedef typename detail::pointer_to_other
::type pointer; private: typedef sp_counted_impl_pd
counted_impl; typedef typename detail::pointer_to_other
::type counted_impl_ptr; typedef typename detail::pointer_to_other
::type counted_base_ptr; pointer m_px; counted_impl_ptr m_pi; template
friend class weak_count; template
friend class shared_count; public: weak_count(): m_px(0), m_pi(0) // nothrow {} template
explicit weak_count(shared_count
const & r) : m_px(r.m_px), m_pi(r.m_pi) // nothrow { if(m_pi != 0) m_pi->weak_add_ref(); } weak_count(weak_count const & r) : m_px(r.m_px), m_pi(r.m_pi) // nothrow { if(m_pi != 0) m_pi->weak_add_ref(); } template
weak_count(weak_count
const & r) : m_px(r.m_px), m_pi(r.m_pi) // nothrow { if(m_pi != 0) m_pi->weak_add_ref(); } ~weak_count() // nothrow { if(m_pi != 0) m_pi->weak_release(); } template
weak_count & operator= (shared_count
const & r) // nothrow { m_px = r.m_px; counted_impl_ptr tmp = r.m_pi; if(tmp != 0) tmp->weak_add_ref(); if(m_pi != 0) m_pi->weak_release(); m_pi = tmp; return *this; } weak_count & operator= (weak_count const & r) // nothrow { counted_impl_ptr tmp = r.m_pi; if(tmp != 0) tmp->weak_add_ref(); if(m_pi != 0) m_pi->weak_release(); m_pi = tmp; return *this; } void set_pointer(const pointer &ptr) { m_px = ptr; } template
weak_count & operator= (weak_count
const& r) // nothrow { counted_impl_ptr tmp = r.m_pi; if(tmp != 0) tmp->weak_add_ref(); if(m_pi != 0) m_pi->weak_release(); m_pi = tmp; return *this; } void swap(weak_count & r) // nothrow { detail::do_swap(m_px, r.m_px); detail::do_swap(m_pi, r.m_pi); } long use_count() const // nothrow { return m_pi != 0? m_pi->use_count() : 0; } template
bool internal_equal (weak_count
const & other) const { return this->m_pi == other.m_pi; } template
bool internal_less (weak_count
const & other) const { return std::less
()(this->m_pi, other.m_pi); } }; template
inline bool operator==(weak_count
const & a, weak_count
const & b) { return a.internal_equal(b); } template
inline bool operator<(weak_count
const & a, weak_count
const & b) { return a.internal_less(b); } } // namespace detail } // namespace interprocess } // namespace boost #include
#endif // #ifndef BOOST_INTERPROCESS_DETAIL_SHARED_COUNT_HPP_INCLUDED
shared_count.hpp
网页地址
文件地址
上一页
2/5
下一页
下载
( 10 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.