zwoop commented on code in PR #13188:
URL: https://github.com/apache/trafficserver/pull/13188#discussion_r3284754761
##########
include/ts/ts.h:
##########
@@ -1168,6 +1168,26 @@ TSReturnCode TSMutexLockTry(TSMutex mutexp);
void TSMutexUnlock(TSMutex mutexp);
+/** Scoped lock guard for a @c TSMutex.
+
+ Locks @a mutexp on construction and unlocks it when the guard leaves scope.
+ */
+class TSMutexLockGuard
+{
+public:
+ explicit TSMutexLockGuard(TSMutex mutexp) : m_mutex(mutexp) {
TSMutexLock(m_mutex); }
Review Comment:
```
[[nodiscard("Did you forget to name your lock guard variable?")]]
explicit TSMutexLockGuard(TSMutex mutexp) : m_mutex(mutexp) {
TSMutexLock(m_mutex); }
```
or some such ? This prevents a user from accidentally making a no-op lock
guard (which almost certainly is not what they want). Albeit nitpicky, it feels
useful in a public (plugin) API.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]