barrier.hpp 1022 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright Oliver Kowalke 2013.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_FIBERS_BARRIER_H
  6. #define BOOST_FIBERS_BARRIER_H
  7. #include <cstddef>
  8. #include <boost/config.hpp>
  9. #include <boost/fiber/condition_variable.hpp>
  10. #include <boost/fiber/detail/config.hpp>
  11. #include <boost/fiber/mutex.hpp>
  12. #ifdef BOOST_HAS_ABI_HEADERS
  13. # include BOOST_ABI_PREFIX
  14. #endif
  15. namespace boost {
  16. namespace fibers {
  17. class BOOST_FIBERS_DECL barrier {
  18. private:
  19. std::size_t initial_;
  20. std::size_t current_;
  21. std::size_t cycle_{ 0 };
  22. mutex mtx_{};
  23. condition_variable cond_{};
  24. public:
  25. explicit barrier( std::size_t);
  26. barrier( barrier const&) = delete;
  27. barrier & operator=( barrier const&) = delete;
  28. bool wait();
  29. };
  30. }}
  31. #ifdef BOOST_HAS_ABI_HEADERS
  32. # include BOOST_ABI_SUFFIX
  33. #endif
  34. #endif // BOOST_FIBERS_BARRIER_H