x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
interprocess_semaphore.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\interprocess\sync\interprocess_semaphore.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_SEMAPHORE_HPP #define BOOST_INTERPROCESS_SEMAPHORE_HPP #if (defined _MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif #include
#include
#include
#include
#include
#if defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED &&\ defined BOOST_INTERPROCESS_POSIX_SEMAPHORES #include
//O_CREAT, O_*... #include
//close #include
//std::string #include
//sem_* family, SEM_VALUE_MAX #include
//mode_t, S_IRWXG, S_IRWXO, S_IRWXU, #include
#define BOOST_INTERPROCESS_USE_POSIX #else #include
#include
#include
#include
#include
#define BOOST_INTERPROCESS_USE_GENERIC_EMULATION #endif //!\file //!Describes a interprocess_semaphore class for inter-process synchronization namespace boost { namespace interprocess { //!Wraps a interprocess_semaphore that can be placed in shared memory and can be //!shared between processes. Allows timed lock tries class interprocess_semaphore { /// @cond //Non-copyable interprocess_semaphore(const interprocess_semaphore &); interprocess_semaphore &operator=(const interprocess_semaphore &); /// @endcond public: //!Creates a interprocess_semaphore with the given initial count. //!interprocess_exception if there is an error.*/ interprocess_semaphore(int initialCount); //!Destroys the interprocess_semaphore. //!Does not throw ~interprocess_semaphore(); //!Increments the interprocess_semaphore count. If there are processes/threads blocked waiting //!for the interprocess_semaphore, then one of these processes will return successfully from //!its wait function. If there is an error an interprocess_exception exception is thrown. void post(); //!Decrements the interprocess_semaphore. If the interprocess_semaphore value is not greater than zero, //!then the calling process/thread blocks until it can decrement the counter. //!If there is an error an interprocess_exception exception is thrown. void wait(); //!Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero //!and returns true. If the value is not greater than zero returns false. //!If there is an error an interprocess_exception exception is thrown. bool try_wait(); //!Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater //!than zero and returns true. Otherwise, waits for the interprocess_semaphore //!to the posted or the timeout expires. If the timeout expires, the //!function returns false. If the interprocess_semaphore is posted the function //!returns true. If there is an error throws sem_exception bool timed_wait(const boost::posix_time::ptime &abs_time); //!Returns the interprocess_semaphore count // int get_count() const; /// @cond private: #if defined(BOOST_INTERPROCESS_USE_GENERIC_EMULATION) interprocess_mutex m_mut; interprocess_condition m_cond; int m_count; #else detail::semaphore_wrapper m_sem; #endif //#if defined(BOOST_INTERPROCESS_USE_GENERIC_EMULATION) /// @endcond }; } //namespace interprocess { } //namespace boost { #ifdef BOOST_INTERPROCESS_USE_GENERIC_EMULATION # undef BOOST_INTERPROCESS_USE_GENERIC_EMULATION # include
#endif #ifdef BOOST_INTERPROCESS_USE_POSIX # undef BOOST_INTERPROCESS_USE_POSIX # include
#endif #include
#endif //BOOST_INTERPROCESS_SEMAPHORE_HPP
interprocess_semaphore.hpp
网页地址
文件地址
上一页
6/18
下一页
下载
( 4 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.