1 /* Copyright (c) 2006-2015. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_S4U_MUTEX_HPP
7 #define SIMGRID_S4U_MUTEX_HPP
12 #include <boost/intrusive_ptr.hpp>
15 #include "simgrid/simix.h"
20 class ConditionVariable;
22 XBT_PUBLIC_CLASS Mutex {
23 friend ConditionVariable;
25 friend simgrid::simix::Mutex;
26 simgrid::simix::Mutex* mutex_;
27 Mutex(simgrid::simix::Mutex* mutex) : mutex_(mutex) {}
30 friend void intrusive_ptr_add_ref(Mutex* mutex)
33 SIMIX_mutex_ref(mutex->mutex_);
35 friend void intrusive_ptr_release(Mutex* mutex)
38 SIMIX_mutex_unref(mutex->mutex_);
40 using Ptr = boost::intrusive_ptr<Mutex>;
43 Mutex(Mutex const&) = delete;
44 Mutex& operatori(Mutex const&) = delete;
46 static Ptr createMutex();
54 using MutexPtr = Mutex::Ptr;
56 }} // namespace simgrid::s4u
58 #endif /* SIMGRID_S4U_MUTEX_HPP */