#include <simgrid/forward.h>
#include <simgrid/chrono.hpp>
+#include <simgrid/s4u/Engine.hpp>
#include <simgrid/s4u/Mutex.hpp>
#include <future>
namespace 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++ <https://en.cppreference.com/w/cpp/thread/condition_variable>`_
* for more information on condition variables. A SimGrid example is available in Section :ref:`s4u_ex_IPC`.
*/
class XBT_PUBLIC ConditionVariable {
private:
+#ifndef DOXYGEN
friend kernel::activity::ConditionVariableImpl;
- kernel::activity::ConditionVariableImpl* const cond_;
+ friend 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;
friend XBT_PUBLIC void intrusive_ptr_release(const ConditionVariable* cond);
#endif
+public:
/** 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
*/
/// As long as the predicate is false, wait for the given amount of seconds (specified as a plain double)
template <class P> bool wait_for(const std::unique_lock<s4u::Mutex>& 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: