x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
pthread_helpers.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\interprocess\sync\posix\pthread_helpers.hpp
旋转
特效
属性
历史版本
////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2005-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_PTHREAD_HELPERS_HPP #define BOOST_INTERPROCESS_PTHREAD_HELPERS_HPP #if (defined _MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif #include
#include
#include
#include
#include
namespace boost { namespace interprocess { namespace detail{ #if defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED //!Makes pthread_mutexattr_t cleanup easy when using exceptions struct mutexattr_wrapper { //!Constructor mutexattr_wrapper(bool recursive = false) { if(pthread_mutexattr_init(&m_attr)!=0 || pthread_mutexattr_setpshared(&m_attr, PTHREAD_PROCESS_SHARED)!= 0 || (recursive && pthread_mutexattr_settype(&m_attr, PTHREAD_MUTEX_RECURSIVE)!= 0 )) throw boost::interprocess::interprocess_exception(); } //!Destructor ~mutexattr_wrapper() { pthread_mutexattr_destroy(&m_attr); } //!This allows using mutexattr_wrapper as pthread_mutexattr_t operator pthread_mutexattr_t&() { return m_attr; } pthread_mutexattr_t m_attr; }; //!Makes pthread_condattr_t cleanup easy when using exceptions struct condattr_wrapper { //!Constructor condattr_wrapper() { if(pthread_condattr_init(&m_attr)!=0 || pthread_condattr_setpshared(&m_attr, PTHREAD_PROCESS_SHARED)!= 0) throw boost::interprocess::interprocess_exception(); } //!Destructor ~condattr_wrapper() { pthread_condattr_destroy(&m_attr); } //!This allows using condattr_wrapper as pthread_condattr_t operator pthread_condattr_t&(){ return m_attr; } pthread_condattr_t m_attr; }; //!Makes initialized pthread_mutex_t cleanup easy when using exceptions class mutex_initializer { public: //!Constructor. Takes interprocess_mutex attributes to initialize the interprocess_mutex mutex_initializer(pthread_mutex_t &mut, pthread_mutexattr_t &mut_attr) : mp_mut(&mut) { if(pthread_mutex_init(mp_mut, &mut_attr) != 0) throw boost::interprocess::interprocess_exception(); } ~mutex_initializer() { if(mp_mut) pthread_mutex_destroy(mp_mut); } void release() {mp_mut = 0; } private: pthread_mutex_t *mp_mut; }; //!Makes initialized pthread_cond_t cleanup easy when using exceptions class condition_initializer { public: condition_initializer(pthread_cond_t &cond, pthread_condattr_t &cond_attr) : mp_cond(&cond) { if(pthread_cond_init(mp_cond, &cond_attr)!= 0) throw boost::interprocess::interprocess_exception(); } ~condition_initializer() { if(mp_cond) pthread_cond_destroy(mp_cond); } void release() { mp_cond = 0; } private: pthread_cond_t *mp_cond; }; #endif // #if defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED #if defined(BOOST_INTERPROCESS_POSIX_BARRIERS) && defined(BOOST_INTERPROCESS_POSIX_PROCESS_SHARED) //!Makes pthread_barrierattr_t cleanup easy when using exceptions struct barrierattr_wrapper { //!Constructor barrierattr_wrapper() { if(pthread_barrierattr_init(&m_attr)!=0 || pthread_barrierattr_setpshared(&m_attr, PTHREAD_PROCESS_SHARED)!= 0) throw boost::interprocess::interprocess_exception(); } //!Destructor ~barrierattr_wrapper() { pthread_barrierattr_destroy(&m_attr); } //!This allows using mutexattr_wrapper as pthread_barrierattr_t operator pthread_barrierattr_t&() { return m_attr; } pthread_barrierattr_t m_attr; }; //!Makes initialized pthread_barrier_t cleanup easy when using exceptions class barrier_initializer { public: //!Constructor. Takes barrier attributes to initialize the barrier barrier_initializer(pthread_barrier_t &mut, pthread_barrierattr_t &mut_attr, int count) : mp_barrier(&mut) { if(pthread_barrier_init(mp_barrier, &mut_attr, count) != 0) throw boost::interprocess::interprocess_exception(); } ~barrier_initializer() { if(mp_barrier) pthread_barrier_destroy(mp_barrier); } void release() {mp_barrier = 0; } private: pthread_barrier_t *mp_barrier; }; #endif //#if defined(BOOST_INTERPROCESS_POSIX_BARRIERS) && defined(BOOST_INTERPROCESS_POSIX_PROCESS_SHARED) }//namespace detail }//namespace interprocess }//namespace boost #include
#endif //ifdef BOOST_INTERPROCESS_PTHREAD_HELPERS_HPP
pthread_helpers.hpp
网页地址
文件地址
上一页
6/8
下一页
下载
( 5 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.