ManaPlus
Public Member Functions | Private Attributes
Mutex Class Reference

#include <mutex.h>

Public Member Functions

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

Private Attributes

SDL_mutex * mMutex
 

Detailed Description

A mutex provides mutual exclusion of access to certain data that is accessed by multiple threads.

Definition at line 33 of file mutex.h.

Constructor & Destructor Documentation

◆ Mutex()

Mutex::Mutex ( )
inline

Definition at line 75 of file mutex.h.

75  :
76  mMutex(SDL_CreateMutex())
77 {
78 }
SDL_mutex * mMutex
Definition: mutex.h:50

◆ ~Mutex()

Mutex::~Mutex ( )
inline

Definition at line 80 of file mutex.h.

81 {
82  SDL_DestroyMutex(mMutex);
83 }

References mMutex.

Member Function Documentation

◆ lock()

void Mutex::lock ( )
inline

Definition at line 85 of file mutex.h.

86 {
87  if (SDL_mutexP(mMutex) == -1)
88  logger->log("Mutex locking failed: %s", SDL_GetError());
89 }
void log(const char *const log_text,...)
Definition: logger.cpp:269
Logger * logger
Definition: logger.cpp:89

References Logger::log(), logger, and mMutex.

Referenced by MutexLocker::MutexLocker().

◆ unlock()

void Mutex::unlock ( )
inline

Definition at line 91 of file mutex.h.

92 {
93  if (SDL_mutexV(mMutex) == -1)
94  logger->log("Mutex unlocking failed: %s", SDL_GetError());
95 }

References Logger::log(), logger, and mMutex.

Referenced by MutexLocker::~MutexLocker().

Field Documentation

◆ mMutex

SDL_mutex* Mutex::mMutex
private

Definition at line 50 of file mutex.h.

Referenced by lock(), unlock(), and ~Mutex().


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