Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115402
D7879.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D7879.diff
View Options
diff --git a/src/sync.h b/src/sync.h
--- a/src/sync.h
+++ b/src/sync.h
@@ -53,8 +53,9 @@
void CheckLastCritical(void *cs, std::string &lockname, const char *guardname,
const char *file, int line);
std::string LocksHeld();
+template <typename MutexType>
void AssertLockHeldInternal(const char *pszName, const char *pszFile, int nLine,
- void *cs) ASSERT_EXCLUSIVE_LOCK(cs);
+ MutexType *cs) ASSERT_EXCLUSIVE_LOCK(cs);
void AssertLockNotHeldInternal(const char *pszName, const char *pszFile,
int nLine, void *cs);
void DeleteLock(void *cs);
@@ -72,9 +73,11 @@
static inline void CheckLastCritical(void *cs, std::string &lockname,
const char *guardname, const char *file,
int line) {}
+template <typename MutexType>
static inline void AssertLockHeldInternal(const char *pszName,
const char *pszFile, int nLine,
- void *cs) ASSERT_EXCLUSIVE_LOCK(cs) {}
+ MutexType *cs)
+ ASSERT_EXCLUSIVE_LOCK(cs) {}
static inline void AssertLockNotHeldInternal(const char *pszName,
const char *pszFile, int nLine,
void *cs) {}
diff --git a/src/sync.cpp b/src/sync.cpp
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -218,8 +218,9 @@
return false;
}
+template <typename MutexType>
void AssertLockHeldInternal(const char *pszName, const char *pszFile, int nLine,
- void *cs) {
+ MutexType *cs) {
if (LockHeld(cs)) {
return;
}
@@ -228,6 +229,9 @@
pszName, pszFile, nLine, LocksHeld());
abort();
}
+template void AssertLockHeldInternal(const char *, const char *, int, Mutex *);
+template void AssertLockHeldInternal(const char *, const char *, int,
+ RecursiveMutex *);
void AssertLockNotHeldInternal(const char *pszName, const char *pszFile,
int nLine, void *cs) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:03 (15 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187464
Default Alt Text
D7879.diff (2 KB)
Attached To
D7879: Use template function instead of void* parameter
Event Timeline
Log In to Comment