Xmipp  v3.23.11-Nereus
Public Member Functions | Friends | List of all members
Mutex Class Reference

#include <xmipp_threads.h>

Inheritance diagram for Mutex:
Inheritance graph
[legend]

Public Member Functions

 Mutex ()
 
virtual ~Mutex ()
 
virtual void lock ()
 
virtual void unlock ()
 

Friends

class Condition
 

Detailed Description

Class wrapping around the pthreads mutex. This class will provide a more object oriented implementation of a mutex, to ensure the unique access to critical regions of code and other synchronization problems.

Definition at line 52 of file xmipp_threads.h.

Constructor & Destructor Documentation

◆ Mutex()

Mutex::Mutex ( )

Default constructor. This constructor just initialize the pthread_mutex_t structure with its defaults values, just like static initialization with PTHREAD_MUTEX_INITIALIZER

Definition at line 36 of file xmipp_threads.cpp.

37 {
38  pthread_mutex_init(&mutex, NULL);
39 }
Mutex mutex

◆ ~Mutex()

Mutex::~Mutex ( )
virtual

Destructor.

Definition at line 41 of file xmipp_threads.cpp.

42 {
43  pthread_mutex_destroy(&mutex);
44 }
Mutex mutex

Member Function Documentation

◆ lock()

void Mutex::lock ( )
virtual

Function to get the access to the mutex. If the some thread has the mutex and other ask to lock will be waiting until the first one release the mutex

Reimplemented in MpiFileMutex.

Definition at line 46 of file xmipp_threads.cpp.

47 {
48  pthread_mutex_lock(&mutex);
49 }
Mutex mutex

◆ unlock()

void Mutex::unlock ( )
virtual

Function to release the mutex. This allow the access to the mutex to other threads that are waiting for it.

Reimplemented in MpiFileMutex.

Definition at line 51 of file xmipp_threads.cpp.

52 {
53  pthread_mutex_unlock(&mutex);
54 }
Mutex mutex

Friends And Related Function Documentation

◆ Condition

friend class Condition
friend

Definition at line 80 of file xmipp_threads.h.


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