1 // Copyright (C) 2002-2003
2 // David Moore, William E. Kempf
3 // Copyright (C) 2007-8 Anthony Williams
5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_BARRIER_JDM030602_HPP
9 #define BOOST_BARRIER_JDM030602_HPP
11 #include <boost/thread/detail/config.hpp>
13 #include <boost/thread/mutex.hpp>
14 #include <boost/thread/condition_variable.hpp>
18 #include <boost/config/abi_prefix.hpp>
26 barrier(unsigned int count
)
27 : m_threshold(count
), m_count(count
), m_generation(0)
30 throw std::invalid_argument("count cannot be zero.");
35 boost::mutex::scoped_lock
lock(m_mutex
);
36 unsigned int gen
= m_generation
;
41 m_count
= m_threshold
;
46 while (gen
== m_generation
)
53 condition_variable m_cond
;
54 unsigned int m_threshold
;
56 unsigned int m_generation
;
61 #include <boost/config/abi_suffix.hpp>