X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/08e7455d67920bbd7a87f440d00f2c1e071314a0..7435797a62213e9e99d48c5968d273f6396ed988:/include/simgrid/s4u/ConditionVariable.hpp diff --git a/include/simgrid/s4u/ConditionVariable.hpp b/include/simgrid/s4u/ConditionVariable.hpp index 558b5cd9c9..f2f0744c29 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,15 +9,15 @@ #include #include +#include #include #include -namespace simgrid { -namespace s4u { +namespace simgrid::s4u { /** - * @rst + * @beginrst * SimGrid's condition variables are meant to be drop-in replacements of ``std::condition_variable``. * Please refer to the `documentation of standard C++ `_ * for more information on condition variables. A SimGrid example is available in Section :ref:`s4u_ex_IPC`. @@ -25,13 +25,16 @@ namespace s4u { */ class XBT_PUBLIC ConditionVariable { private: +#ifndef DOXYGEN friend kernel::activity::ConditionVariableImpl; - kernel::activity::ConditionVariableImpl* const cond_; + friend XBT_PUBLIC void kernel::activity::intrusive_ptr_release(kernel::activity::ConditionVariableImpl* cond); +#endif -public: -#ifndef DOXYGEN - explicit ConditionVariable(kernel::activity::ConditionVariableImpl* cond) : cond_(cond) {} + kernel::activity::ConditionVariableImpl* const pimpl_; + explicit ConditionVariable(kernel::activity::ConditionVariableImpl* cond) : pimpl_(cond) {} + ~ConditionVariable() = default; +#ifndef DOXYGEN ConditionVariable(ConditionVariable const&) = delete; ConditionVariable& operator=(ConditionVariable const&) = delete; @@ -39,9 +42,10 @@ public: friend XBT_PUBLIC void intrusive_ptr_release(const ConditionVariable* cond); #endif - /** Create a new condition variable and return a smart pointer +public: + /** \static Create a new condition variable and return a smart pointer * - * @rst + * @beginrst * You should only manipulate :cpp:type:`simgrid::s4u::ConditionVariablePtr`, as created by this function (see also :ref:`s4u_raii`). * @endrst */ @@ -72,7 +76,7 @@ public: /// 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)); + return this->wait_until(lock, Engine::get_clock() + duration, std::move(pred)); } // Wait function taking a C++ style time: @@ -112,7 +116,6 @@ public: void notify_all(); }; -} // namespace s4u -} // namespace simgrid +} // namespace simgrid::s4u #endif