X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/222e031aa69b85a660b37e558115375d44ec3f68..ec02e7dbba648af74ef31ac28929d153db6d53f5:/include/simgrid/s4u/ConditionVariable.hpp diff --git a/include/simgrid/s4u/ConditionVariable.hpp b/include/simgrid/s4u/ConditionVariable.hpp index e18b846020..448b4a8391 100644 --- a/include/simgrid/s4u/ConditionVariable.hpp +++ b/include/simgrid/s4u/ConditionVariable.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -9,12 +9,12 @@ #include #include +#include #include #include -namespace simgrid { -namespace s4u { +namespace simgrid::s4u { /** * @beginrst @@ -25,12 +25,16 @@ namespace s4u { */ class XBT_PUBLIC ConditionVariable { private: +#ifndef DOXYGEN friend kernel::activity::ConditionVariableImpl; + friend XBT_PUBLIC void kernel::activity::intrusive_ptr_release(kernel::activity::ConditionVariableImpl* cond); +#endif + kernel::activity::ConditionVariableImpl* const pimpl_; -#ifndef DOXYGEN explicit ConditionVariable(kernel::activity::ConditionVariableImpl* cond) : pimpl_(cond) {} - + ~ConditionVariable() = default; +#ifndef DOXYGEN ConditionVariable(ConditionVariable const&) = delete; ConditionVariable& operator=(ConditionVariable const&) = delete; @@ -39,7 +43,7 @@ private: #endif public: - /** Create a new condition variable and return a smart pointer + /** \static Create a new condition variable and return a smart pointer * * @beginrst * You should only manipulate :cpp:type:`simgrid::s4u::ConditionVariablePtr`, as created by this function (see also :ref:`s4u_raii`). @@ -61,29 +65,9 @@ public: std::cv_status wait_until(const std::unique_lock& lock, double timeout_time); /// Wait for the given amount of seconds (specified as a plain double) std::cv_status wait_for(const std::unique_lock& lock, double duration); - /// Wait until predicate is true, or the given instant (specified as a plain double) - template bool wait_until(const std::unique_lock& lock, double timeout_time, P pred) - { - while (not pred()) - if (this->wait_until(lock, timeout_time) == std::cv_status::timeout) - return pred(); - return true; - } - /// As long as the predicate is false, wait for the given amount of seconds (specified as a plain double) - template bool wait_for(const std::unique_lock& lock, double duration, P pred) - { - return this->wait_until(lock, SIMIX_get_clock() + duration, std::move(pred)); - } // Wait function taking a C++ style time: - /// As long as the predicate is false, wait for the given amount of seconds (specified in C++ style) - template - bool wait_for(const std::unique_lock& lock, std::chrono::duration duration, P pred) - { - auto seconds = std::chrono::duration_cast(duration); - return this->wait_for(lock, seconds.count(), pred); - } /// Wait for the given amount of seconds (specified in C++ style) template std::cv_status wait_for(const std::unique_lock& lock, std::chrono::duration duration) @@ -98,13 +82,6 @@ public: auto timeout_native = std::chrono::time_point_cast(timeout_time); return this->wait_until(lock, timeout_native.time_since_epoch().count()); } - /** Wait until predicate is true, or the given instant (specified in C++ style) */ - template - bool wait_until(const std::unique_lock& lock, const SimulationTimePoint& timeout_time, P pred) - { - auto timeout_native = std::chrono::time_point_cast(timeout_time); - return this->wait_until(lock, timeout_native.time_since_epoch().count(), std::move(pred)); - } /** Unblock one actor blocked on that condition variable. If none was blocked, nothing happens. */ void notify_one(); @@ -112,7 +89,6 @@ public: void notify_all(); }; -} // namespace s4u -} // namespace simgrid +} // namespace simgrid::s4u #endif