yanglimingcn commented on PR #2215:
URL: https://github.com/apache/brpc/pull/2215#issuecomment-1525526114

   > > > 需要考虑线程池退出问题吗?
   > > 
   > > 
   > > 这块参考了usercode backup pool的实现,它里面有个注释,所以我这块好像也得按照这个方式处理。 int 
UserCodeBackupPool::Init() { // Like bthread workers, these threads never quit 
(to avoid potential hang // during termination of program). for (int i = 0; i < 
FLAGS_usercode_backup_threads; ++i) { pthread_t th; if (pthread_create(&th, 
NULL, UserCodeRunner, this) != 0) { LOG(ERROR) << "Fail to create 
UserCodeRunner"; return -1; } } return 0; }
   > 
   > UserCodeBackupPool是框架里使用的,进程运行时是不会析构的。
   > 
   > ```c++
   > static UserCodeBackupPool* s_usercode_pool = NULL;
   > ```
   > 
   > 
该PR里的UserCodeThreadPool是给用户使用的,UserCodeThreadPool有可能会析构,但是线程池里的线程没有退出,有crash的可能。
   > 
   > 在UserCodeThreadPool析构函数中做一下stop and join操作,是不是合理一些呢?
   
   
看代码Server退出的时候都应该调用Server::Join()这个函数,这个函数执行完,应该就没有新的请求了,然后Server析构函数中析构_thread_pool_map的时候去UserCodeThreadPool里面调用stop
 and join,我觉得这样是合理的。
   UserCodeBackupPool如果在Server里面析构了应该会造成死锁问题,UserCodeThreadPool应该没有这种问题。
   
   


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