1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #include<boost/interprocess/exceptions.hpp>
12 #include <boost/interprocess/sync/scoped_lock.hpp>
14 #ifndef BOOST_CONFIG_HPP
15 # include <boost/config.hpp>
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
23 namespace interprocess {
25 inline barrier::barrier(unsigned int count)
26 : m_threshold(count), m_count(count), m_generation(0)
29 throw std::invalid_argument("count cannot be zero.");
32 inline barrier::~barrier(){}
34 inline bool barrier::wait()
36 scoped_lock<interprocess_mutex> lock(m_mutex);
37 unsigned int gen = m_generation;
41 m_count = m_threshold;
46 while (gen == m_generation){
52 } //namespace interprocess {