ddnet/src/base/lock_scope.h
Dennis Felsing ef174a58a8 Fix TSA warnings in Clang 15 (fixes #5548)
src/engine/client/serverbrowser_http.cpp:147:1: warning: mutex 'ls.m_Lock' is still held at the end of function [-Wthread-safety-analysis]
}
^
2022-09-15 23:31:09 +02:00

25 lines
315 B
C++

#ifndef BASE_LOCK_SCOPE_H
#define BASE_LOCK_SCOPE_H
#include "system.h"
class SCOPED_CAPABILITY CLockScope
{
public:
CLockScope(LOCK Lock) ACQUIRE(Lock, m_Lock) :
m_Lock(Lock)
{
lock_wait(m_Lock);
}
~CLockScope() RELEASE() REQUIRES(m_Lock)
{
lock_unlock(m_Lock);
}
private:
LOCK m_Lock;
};
#endif