walterzhaoJR commented on code in PR #3417:
URL: https://github.com/apache/brpc/pull/3417#discussion_r3709194980


##########
src/bthread/mutex.cpp:
##########
@@ -1190,6 +1190,46 @@ bool FastPthreadMutex::timed_lock(const struct timespec* 
abstime) {
 }
 #endif // BTHREAD_USE_FAST_PTHREAD_MUTEX HAS_PTHREAD_MUTEX_TIMEDLOCK
 
+enum RecursiveMutexOwnerKind {
+    RECURSIVE_MUTEX_UNOWNED = 0,
+    RECURSIVE_MUTEX_BTHREAD = 1,
+    RECURSIVE_MUTEX_PTHREAD = 2,
+};
+
+struct RecursiveMutexOwner {
+    uint64_t id;
+    uint32_t kind;
+};
+
+static __thread char tls_recursive_mutex_owner;

Review Comment:
   The value itself is intentionally unused. When bthread_self() returns 
INVALID_BTHREAD, we need another way to identify the current native pthread. 
Each live pthread has its own TLS instance, whose address remains stable for 
the thread's lifetime, so we use that address as the owner token.
   
   I renamed the variable to tls_recursive_mutex_owner_token and added a 
comment to clarify this.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to