1 // Distributed under the Boost Software License, Version 1.0. (See
2 // accompanying file LICENSE_1_0.txt or copy at
3 // http://www.boost.org/LICENSE_1_0.txt)
4 // (C) Copyright 2013 Vicente J. Botet Escriba
6 #ifndef BOOST_THREAD_COUNTER_HPP
7 #define BOOST_THREAD_COUNTER_HPP
9 #include <boost/thread/detail/config.hpp>
10 #include <boost/thread/detail/delete.hpp>
12 //#include <boost/thread/mutex.hpp>
13 //#include <boost/thread/lock_types.hpp>
14 #include <boost/thread/condition_variable.hpp>
15 #include <boost/chrono/duration.hpp>
16 #include <boost/chrono/time_point.hpp>
17 #include <boost/assert.hpp>
19 #include <boost/config/abi_prefix.hpp>
26 condition_variable cond_;
29 counter(std::size_t value)
34 counter& operator=(counter const& rhs)
39 counter& operator=(std::size_t value)
45 operator std::size_t() const
49 operator std::size_t&()
54 void inc_and_notify_all()
60 void dec_and_notify_all()
65 void assign_and_notify_all(counter const& rhs)
70 void assign_and_notify_all(std::size_t value)
76 struct counter_is_not_zero
78 counter_is_not_zero(counter const& count) : count_(count) {}
79 bool operator()() const { return count_ != 0; }
80 counter const& count_;
82 struct counter_is_zero
84 counter_is_zero(counter const& count) : count_(count) {}
85 bool operator()() const { return count_ == 0; }
86 counter const& count_;
90 is_zero(std::size_t& count) : count_(count) {}
91 bool operator()() const { return count_ == 0; }
96 not_equal(std::size_t& x, std::size_t& y) : x_(x), y_(y) {}
97 bool operator()() const { return x_ != y_; }
104 #include <boost/config/abi_suffix.hpp>