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/detail/posix_time_types_wrk.hpp>
13 #include <boost/interprocess/sync/scoped_lock.hpp>
15 #ifndef BOOST_CONFIG_HPP
16 # include <boost/config.hpp>
19 #if defined(BOOST_HAS_PRAGMA_ONCE)
24 namespace interprocess {
26 inline barrier::barrier(unsigned int count)
27 : m_threshold(count), m_count(count), m_generation(0)
30 throw std::invalid_argument("count cannot be zero.");
33 inline barrier::~barrier(){}
35 inline bool barrier::wait()
37 scoped_lock<interprocess_mutex> lock(m_mutex);
38 unsigned int gen = m_generation;
42 m_count = m_threshold;
47 while (gen == m_generation){
53 } //namespace interprocess {