ddnet/src/base/lock_scope.h

25 lines
315 B
C
Raw Normal View History

#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