Re: [PR] Support bthread_usleep to wait for Singleton on bthread (brpc)

2024-01-25 Thread via GitHub


chenBright closed pull request #2517: Support bthread_usleep to wait for 
Singleton on bthread
URL: https://github.com/apache/brpc/pull/2517


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



Re: [PR] Support bthread_usleep to wait for Singleton on bthread (brpc)

2024-01-25 Thread via GitHub


chenBright commented on PR #2517:
URL: https://github.com/apache/brpc/pull/2517#issuecomment-1910054663

   关闭该PR,因为可能会导致线程锁里调Singleton场景出现死锁问题。
   
   有在构造函数中挂起协程操作的需求,可以使用 #2520 的特性。


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



[PR] Support bthread_usleep to wait for Singleton in bthread (brpc)

2024-01-20 Thread via GitHub


chenBright opened a new pull request, #2517:
URL: https://github.com/apache/brpc/pull/2517

   ### What problem does this PR solve?
   
   Issue Number:
   
   Problem Summary:
   
   
对于::Singleton,在T构造的时候,并发调用`get()`,只有一个线程会调用T的构造函数,其他线程会在`WaitForInstance`函数中等待(自旋+`sched_yield`)T完成构造。如果T构造函数中有挂起bthrea的操作,并发大的情况下,有可能会导致“死锁”问题:所有worker线程都在`WaitForInstance`函数中等待T完成构造,而此时已经没有worker可以调度执行T构造函数的bthread了,即T已经无法完成构造。
   
   ### What is changed and the side effects?
   
   Changed:
   
   在链接了bthread时,使用bthread_yield,这样在bthread上使用的:Singleton就不会阻塞所有worker线程了。
   
   Side effects:
   - Performance effects(性能影响):
   
   - Breaking backward compatibility(向后兼容性): 
   
   ---
   ### Check List:
   - Please make sure your changes are compilable(请确保你的更改可以通过编译).
   - When providing us with a new feature, it is best to add related 
tests(如果你向我们增加一个新的功能, 请添加相关测试).
   - Please follow [Contributor Covenant Code of 
Conduct](../../master/CODE_OF_CONDUCT.md).(请遵循贡献者准则).
   


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