SimGrid  3.21
Versatile Simulation of Distributed Systems
simgrid::s4u::Mutex Class Reference

Detailed Description

A classical mutex, but blocking in the simulation world

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 <a href="http://en.cppreference.com/w/cpp/thread/mutex>std::mutex.

As for any S4U object, Mutexes are using the RAII idiom for memory management. Use create() to get a simgrid::s4u::MutexPtr to a newly created mutex and only manipulate simgrid::s4u::MutexPtr.

#include <Mutex.hpp>

Public Member Functions

 Mutex (Mutex const &)=delete
 You cannot create a new mutex by copying an existing one. More...
 
Mutexoperator= (Mutex const &)=delete
 You cannot create a new mutex by value assignment either. More...
 
void lock ()
 
void unlock ()
 
bool try_lock ()
 

Static Public Member Functions

static MutexPtr create ()
 Constructs a new mutex. More...
 
static MutexPtr createMutex ()
 

Friends

void intrusive_ptr_add_ref (Mutex *mutex)
 
void intrusive_ptr_release (Mutex *mutex)
 

Constructor & Destructor Documentation

◆ Mutex()

simgrid::s4u::Mutex::Mutex ( Mutex const &  )
delete

You cannot create a new mutex by copying an existing one.

Use MutexPtr instead

Member Function Documentation

◆ operator=()

Mutex& simgrid::s4u::Mutex::operator= ( Mutex const &  )
delete

You cannot create a new mutex by value assignment either.

Use MutexPtr instead

◆ create()

static MutexPtr simgrid::s4u::Mutex::create ( )
static

Constructs a new mutex.

◆ lock()

void simgrid::s4u::Mutex::lock ( )

◆ unlock()

void simgrid::s4u::Mutex::unlock ( )

◆ try_lock()

bool simgrid::s4u::Mutex::try_lock ( )

◆ createMutex()

static MutexPtr simgrid::s4u::Mutex::createMutex ( )
inlinestatic

Friends And Related Function Documentation

◆ intrusive_ptr_add_ref

void intrusive_ptr_add_ref ( Mutex mutex)
friend

◆ intrusive_ptr_release

void intrusive_ptr_release ( Mutex mutex)
friend

The documentation for this class was generated from the following file: