PCB Environment
2
Loading...
Searching...
No Matches
pcbenv
cxx
Util
FancyLock.hpp
1
#ifndef GYM_PCB_UTIL_FANCYLOCK_H
2
#define GYM_PCB_UTIL_FANCYLOCK_H
3
4
#include <mutex>
5
6
// I really want to be able to write WITH_LOCK(...) { }
7
8
struct
fancy_lock_guard
9
{
10
fancy_lock_guard(std::mutex &mutex) : _lock(mutex) { }
11
std::lock_guard<std::mutex> _lock;
12
operator
bool()
const
{
return
true
; }
13
};
14
15
#define WITH_LOCKGUARD(m) if (auto __lock = fancy_lock_guard(m))
16
17
#endif
// GYM_PCB_UTIL_FANCYLOCK_H
Generated by
1.15.0