Skip to content

Commit ba1f095

Browse files
committed
MOVEONLY Move AnnotatedMixin declaration
Move AnnotatedMixin closer to where it's used, and after the DEBUG_LOCKORDER function declarations so it can call them.
1 parent 41b88e9 commit ba1f095

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/sync.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,6 @@ LEAVE_CRITICAL_SECTION(mutex); // no RAII
4646
// //
4747
///////////////////////////////
4848

49-
/**
50-
* Template mixin that adds -Wthread-safety locking
51-
* annotations to a subset of the mutex API.
52-
*/
53-
template <typename PARENT>
54-
class LOCKABLE AnnotatedMixin : public PARENT
55-
{
56-
public:
57-
void lock() EXCLUSIVE_LOCK_FUNCTION()
58-
{
59-
PARENT::lock();
60-
}
61-
62-
void unlock() UNLOCK_FUNCTION()
63-
{
64-
PARENT::unlock();
65-
}
66-
67-
bool try_lock() EXCLUSIVE_TRYLOCK_FUNCTION(true)
68-
{
69-
return PARENT::try_lock();
70-
}
71-
};
72-
7349
#ifdef DEBUG_LOCKORDER
7450
void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false);
7551
void LeaveCritical();
@@ -94,6 +70,30 @@ void static inline DeleteLock(void* cs) {}
9470
#define AssertLockHeld(cs) AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs)
9571
#define AssertLockNotHeld(cs) AssertLockNotHeldInternal(#cs, __FILE__, __LINE__, &cs)
9672

73+
/**
74+
* Template mixin that adds -Wthread-safety locking
75+
* annotations to a subset of the mutex API.
76+
*/
77+
template <typename PARENT>
78+
class LOCKABLE AnnotatedMixin : public PARENT
79+
{
80+
public:
81+
void lock() EXCLUSIVE_LOCK_FUNCTION()
82+
{
83+
PARENT::lock();
84+
}
85+
86+
void unlock() UNLOCK_FUNCTION()
87+
{
88+
PARENT::unlock();
89+
}
90+
91+
bool try_lock() EXCLUSIVE_TRYLOCK_FUNCTION(true)
92+
{
93+
return PARENT::try_lock();
94+
}
95+
};
96+
9797
/**
9898
* Wrapped mutex: supports recursive locking, but no waiting
9999
* TODO: We should move away from using the recursive lock by default.

0 commit comments

Comments
 (0)