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


##########
src/bthread/execution_queue_inl.h:
##########
@@ -234,6 +238,13 @@ friend class TaskIteratorBase;
     clear_task_mem _clear_func;
     ExecutionQueueOptions _options;
     butil::atomic<int>* _join_butex;
+
+    // For pthread mode.
+    pthread_t _pid;
+    bool _pthread_started;
+    butil::Mutex _mutex;

Review Comment:
   
线程模式不同于协程模式,协程模式每次会起一个协程去执行任务,而线程模式在第一次要执行任务时起一个线程,后续通过锁和条件变量来同步。这个锁和条件变量的作用只是通知线程有新的task,继续执行而已,对应的是原来ExecutionQueue起协程的逻辑。
   不用锁的话,就只能像协程模式一样,每次都起一个线程了。这种方式在UT测过,性能是最差的。



##########
src/bthread/execution_queue_inl.h:
##########
@@ -234,6 +238,13 @@ friend class TaskIteratorBase;
     clear_task_mem _clear_func;
     ExecutionQueueOptions _options;
     butil::atomic<int>* _join_butex;
+
+    // For pthread mode.
+    pthread_t _pid;
+    bool _pthread_started;
+    butil::Mutex _mutex;

Review Comment:
   
线程模式不同于协程模式,协程模式每次会起一个协程去执行任务,而线程模式在第一次要执行任务时起一个线程,后续通过锁和条件变量来同步。这个锁和条件变量的作用只是通知线程有新的task,继续执行而已,对应的是原来ExecutionQueue起协程的逻辑。
   不用锁的话,就只能像协程模式一样,每次都起一个线程了。这种方式在UT测过,性能是最差的。



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