/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright 2019 Danny Robson */ #pragma once #include "mutex.hpp" #include namespace cruft::thread { inline namespace win32 { enum class cv_status { no_timeout, timeout }; class condition_variable { public: condition_variable (); condition_variable (condition_variable const&) noexcept = delete; condition_variable& operator= (condition_variable const&) = delete; ~condition_variable (); void notify_one (void) noexcept; void notify_all (void) noexcept; void wait (std::unique_lock&); template void wait ( std::unique_lock &lock, PredicateT pred ) { while (!pred ()) wait (lock); } template cv_status wait_for ( std::unique_lock& lock, std::chrono::duration const &rel_time ); template bool wait_for ( std::unique_lock& lock, std::chrono::duration const &rel_time, PredicateT pred ); private: CONDITION_VARIABLE m_native; }; }; }