X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2ca35a707044d033c33cb4f016e6ffddfded0d05..24de4abff1dbfc7c779f6768186be603342df002:/include/simgrid/s4u/Mutex.hpp diff --git a/include/simgrid/s4u/Mutex.hpp b/include/simgrid/s4u/Mutex.hpp index 241ae36f91..ce19858b40 100644 --- a/include/simgrid/s4u/Mutex.hpp +++ b/include/simgrid/s4u/Mutex.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2015. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2018. 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. */ @@ -11,22 +11,35 @@ #include +#include #include -#include "simgrid/simix.h" namespace simgrid { namespace s4u { class ConditionVariable; -XBT_PUBLIC_CLASS Mutex { -friend ConditionVariable; -private: - friend simgrid::simix::Mutex; - simgrid::simix::Mutex* mutex_; - Mutex(simgrid::simix::Mutex* mutex) : mutex_(mutex) {} -public: +/** @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 + * or pthread_mutex_t, + * because it would block the whole simulation. + * Instead, you should use the present class, that is a drop-in replacement of + * mutex_); } +public: using Ptr = boost::intrusive_ptr; // No copy: + /** You cannot create a new mutex by copying an existing one. Use MutexPtr instead */ Mutex(Mutex const&) = delete; + /** You cannot create a new mutex by value assignment either. Use MutexPtr instead */ Mutex& operator=(Mutex const&) = delete; + /** Constructs a new mutex */ static Ptr createMutex(); -public: void lock(); void unlock(); bool try_lock();