wrapper for OpenMP nested lock routines. More...
#include <Lock.hpp>
Classes | |
| class | Set |
| sets the lock when constructed and unsets when destroyed More... | |
Public Member Functions | |
| Lock (const Lock &) | |
| void | operator= (const Lock &) |
| std::optional< Set > | test () |
If the lock is available, set it and return a Set object. Otherwise, return empty std::optional. | |
| bool | is_set () |
Returns true if the lock is currently set, but leaves it in the same state. | |
wrapper for OpenMP nested lock routines.
This class can be used to prevent data races by OpenMP threads. It contains an OpenMP lock variable. To set the lock, construct a Set object from it. When the Set object is destroyed, the lock will be unset. If Hexed is not compiled with OpenMP, this class does nothing. Use like this:
Lock(const Lock&) and Lock::operator=(const Lock&)) are not thread-safe! You may not copy a Lock that is currently owned by another thread. | bool hexed::Lock::is_set | ( | ) |
Returns true if the lock is currently set, but leaves it in the same state.
Effectively equivalent to bool set; {set = lock.test().has_value();}.
| std::optional< Lock::Set > hexed::Lock::test | ( | ) |
If the lock is available, set it and return a Set object. Otherwise, return empty std::optional.