class ConditionVariable;
/** @brief A classical mutex, but blocking in the simulation world
+ * @ingroup s4u_api
*
* It is strictly impossible to use a real mutex (such as
* [std::mutex](http://en.cppreference.com/w/cpp/thread/mutex)
* Instead, you should use the present class, that is a drop-in replacement of
* [std::mutex](http://en.cppreference.com/w/cpp/thread/mutex).
*
+ * As for any S4U object, Mutexes are using the @ref "RAII idiom" s4u_raii for memory management.
+ * Use createMutex() to get a ::MutexPtr to a newly created mutex and only manipulate ::MutexPtr.
+ *
*/
XBT_PUBLIC_CLASS Mutex {
-friend ConditionVariable;
-private:
+ friend ConditionVariable;
friend simgrid::simix::Mutex;
simgrid::simix::Mutex* mutex_;
Mutex(simgrid::simix::Mutex* mutex) : mutex_(mutex) {}
/** Constructs a new mutex */
static Ptr createMutex();
-public:
void lock();
void unlock();
bool try_lock();