x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
atomic_count.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\detail\atomic_count.hpp
旋转
特效
属性
历史版本
#ifndef BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED #define BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif // // boost/detail/atomic_count.hpp - thread/SMP safe reference counter // // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. // // 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) // // typedef
boost::detail::atomic_count; // // atomic_count a(n); // // (n is convertible to long) // // Effects: Constructs an atomic_count with an initial value of n // // a; // // Returns: (long) the current value of a // // ++a; // // Effects: Atomically increments the value of a // Returns: nothing // // --a; // // Effects: Atomically decrements the value of a // Returns: (long) zero if the new value of a is zero, // unspecified non-zero value otherwise (usually the new value) // // Important note: when --a returns zero, it must act as a // read memory barrier (RMB); i.e. the calling thread must // have a synchronized view of the memory // // On Intel IA-32 (x86) memory is always synchronized, so this // is not a problem. // // On many architectures the atomic instructions already act as // a memory barrier. // // This property is necessary for proper reference counting, since // a thread can update the contents of a shared object, then // release its reference, and another thread may immediately // release the last reference causing object destruction. // // The destructor needs to have a synchronized view of the // object to perform proper cleanup. // // Original example by Alexander Terekhov: // // Given: // // - a mutable shared object OBJ; // - two threads THREAD1 and THREAD2 each holding // a private smart_ptr object pointing to that OBJ. // // t1: THREAD1 updates OBJ (thread-safe via some synchronization) // and a few cycles later (after "unlock") destroys smart_ptr; // // t2: THREAD2 destroys smart_ptr WITHOUT doing any synchronization // with respect to shared mutable object OBJ; OBJ destructors // are called driven by smart_ptr interface... // #include
#ifndef BOOST_HAS_THREADS namespace boost { namespace detail { typedef long atomic_count; } } #elif defined(BOOST_AC_USE_PTHREADS) # include
#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) # include
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) # include
#elif defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 ) # include
#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) # include
#elif defined(BOOST_HAS_PTHREADS) # define BOOST_AC_USE_PTHREADS # include
#else // Use #define BOOST_DISABLE_THREADS to avoid the error #error Unrecognized threading platform #endif #endif // #ifndef BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
atomic_count.hpp
网页地址
文件地址
上一页
3/61
下一页
下载
( 3 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.