Nvwa  1.1
Classes | Namespaces | Macros
fast_mutex.h File Reference

A fast mutex implementation for POSIX, Win32, and modern C++. More...

#include "_nvwa.h"
#include "c++11.h"
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
Include dependency graph for fast_mutex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  nvwa::fast_mutex
 Class for non-reentrant fast mutexes. More...
 
class  nvwa::fast_mutex_autolock
 RAII lock class for fast_mutex. More...
 

Namespaces

 nvwa
 Namespace of the nvwa project.
 

Macros

#define _FAST_MUTEX_CHECK_INITIALIZATION   1
 Macro to control whether to check for initialization status for each lock/unlock operation. More...
 
#define _FAST_MUTEX_ASSERT(_Expr, _Msg)
 Macro for fast_mutex assertions. More...
 
#define __VOLATILE   volatile
 Macro alias to `volatile' semantics. More...
 

Detailed Description

A fast mutex implementation for POSIX, Win32, and modern C++.

Date
2015-05-19

Macro Definition Documentation

◆ __VOLATILE

#define __VOLATILE   volatile

Macro alias to `volatile' semantics.

Here it is truly volatile since it is in a multi-threaded (POSIX threads) environment.

◆ _FAST_MUTEX_ASSERT

#define _FAST_MUTEX_ASSERT (   _Expr,
  _Msg 
)
Value:
if (!(_Expr)) { \
fprintf(stderr, "fast_mutex::%s\n", _Msg); \
abort(); \
}

Macro for fast_mutex assertions.

Real version (for debug mode).

◆ _FAST_MUTEX_CHECK_INITIALIZATION

#define _FAST_MUTEX_CHECK_INITIALIZATION   1

Macro to control whether to check for initialization status for each lock/unlock operation.

Defining it to a non-zero value will enable the check, so that the construction/destruction of a static object using a static fast_mutex not yet constructed or already destroyed will work (with lock/unlock operations ignored). Defining it to zero will disable to check.