diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-02-11 12:14:00 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-02-11 12:14:00 (GMT) |
commit | 0efa7c32aaf21a29b42b5926cc116007056843be (patch) | |
tree | 882f663a5dd0e65694bf6077b71086dd77fd7ff8 /3rdParty/Boost/boost/thread/pthread/once.hpp | |
parent | 1d20eabbc32274b491b4c2bedf73d19933d97bfd (diff) | |
download | swift-contrib-0efa7c32aaf21a29b42b5926cc116007056843be.zip swift-contrib-0efa7c32aaf21a29b42b5926cc116007056843be.tar.bz2 |
Moved some modules into separate git modules.
Diffstat (limited to '3rdParty/Boost/boost/thread/pthread/once.hpp')
m--------- | 3rdParty/Boost | 0 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/thread/pthread/once.hpp | 90 |
2 files changed, 0 insertions, 90 deletions
diff --git a/3rdParty/Boost b/3rdParty/Boost new file mode 160000 +Subproject 3bbdbc8cf1996f23d9a366da8bac0f97be6ad79 diff --git a/3rdParty/Boost/boost/thread/pthread/once.hpp b/3rdParty/Boost/boost/thread/pthread/once.hpp deleted file mode 100644 index f278a57..0000000 --- a/3rdParty/Boost/boost/thread/pthread/once.hpp +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef BOOST_THREAD_PTHREAD_ONCE_HPP -#define BOOST_THREAD_PTHREAD_ONCE_HPP - -// once.hpp -// -// (C) Copyright 2007-8 Anthony Williams -// -// 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) - -#include <boost/thread/detail/config.hpp> - -#include <pthread.h> -#include <boost/assert.hpp> -#include "pthread_mutex_scoped_lock.hpp" -#include <boost/thread/pthread/pthread_mutex_scoped_lock.hpp> -#include <boost/cstdint.hpp> - -#include <boost/config/abi_prefix.hpp> - -namespace boost -{ - - struct once_flag - { - boost::uintmax_t epoch; - }; - - namespace detail - { - BOOST_THREAD_DECL boost::uintmax_t& get_once_per_thread_epoch(); - BOOST_THREAD_DECL extern boost::uintmax_t once_global_epoch; - BOOST_THREAD_DECL extern pthread_mutex_t once_epoch_mutex; - BOOST_THREAD_DECL extern pthread_cond_t once_epoch_cv; - } - -#define BOOST_ONCE_INITIAL_FLAG_VALUE 0 -#define BOOST_ONCE_INIT {BOOST_ONCE_INITIAL_FLAG_VALUE} - - - // Based on Mike Burrows fast_pthread_once algorithm as described in - // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2444.html - template<typename Function> - void call_once(once_flag& flag,Function f) - { - static boost::uintmax_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; - static boost::uintmax_t const being_initialized=uninitialized_flag+1; - boost::uintmax_t const epoch=flag.epoch; - boost::uintmax_t& this_thread_epoch=detail::get_once_per_thread_epoch(); - - if(epoch<this_thread_epoch) - { - pthread::pthread_mutex_scoped_lock lk(&detail::once_epoch_mutex); - - while(flag.epoch<=being_initialized) - { - if(flag.epoch==uninitialized_flag) - { - flag.epoch=being_initialized; - try - { - pthread::pthread_mutex_scoped_unlock relocker(&detail::once_epoch_mutex); - f(); - } - catch(...) - { - flag.epoch=uninitialized_flag; - BOOST_VERIFY(!pthread_cond_broadcast(&detail::once_epoch_cv)); - throw; - } - flag.epoch=--detail::once_global_epoch; - BOOST_VERIFY(!pthread_cond_broadcast(&detail::once_epoch_cv)); - } - else - { - while(flag.epoch==being_initialized) - { - BOOST_VERIFY(!pthread_cond_wait(&detail::once_epoch_cv,&detail::once_epoch_mutex)); - } - } - } - this_thread_epoch=detail::once_global_epoch; - } - } -} - -#include <boost/config/abi_suffix.hpp> - -#endif |