chenBright commented on code in PR #2517:
URL: https://github.com/apache/brpc/pull/2517#discussion_r1461769853


##########
src/butil/memory/singleton.cc:
##########
@@ -5,9 +5,23 @@
 #include "butil/memory/singleton.h"
 #include "butil/threading/platform_thread.h"
 
+__BEGIN_DECLS
+// Defined in bthread/bthread.cpp
+void BAIDU_WEAK bthread_yield();
+__END_DECLS
+
 namespace butil {
 namespace internal {
 
+void yield() {
+    if (bthread_yield) {

Review Comment:
   
或者自旋一定次数后,再调bthread_yield,这样可以自适应地防止死锁问题,不需要用户设置。因为很多时候,用户需要等到死锁了才会发现有bthread_yield的需求。可以自适应的话,可以完全规避这个问题。



-- 
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: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to