hexed 0.3.0
 
Loading...
Searching...
No Matches
hexed::Lock Class Reference

wrapper for OpenMP lock routines. More...

#include <Lock.hpp>

Classes

class  Acquire
 acquires the lock when constructed and releases when destroyed More...
 

Detailed Description

wrapper for OpenMP lock routines.

This class can be used to prevent data races by OpenMP threads. It contains an OpenMP lock variable. To acquire (aka set) the lock, construct an Acquire object from it. When the Acquire object is destroyed, the lock will be released (unset). If Hexed is not compiled with OpenMP, this class does nothing. Use like this:

Lock l;
#pragma omp parallel for
for (int i = 0; i < N; ++i) {
Lock::Acquire a(l); // acquires lock
// only one thread at a time can execute any statements here
} // lock is released because `a` is destroyed
acquires the lock when constructed and releases when destroyed
Definition Lock.hpp:31
wrapper for OpenMP lock routines.
Definition Lock.hpp:25

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