guodongxiaren opened a new issue #1330:
URL: https://github.com/apache/incubator-brpc/issues/1330


   在TaskGroup的主要逻辑wait_task中:
   ```c
   bool TaskGroup::wait_task(bthread_t* tid) {
       do {
   #ifndef BTHREAD_DONT_SAVE_PARKING_STATE
           if (_last_pl_state.stopped()) {
               return false;
           }
           _pl->wait(_last_pl_state);
           if (steal_task(tid)) {
               return true;
           }
   #else
           const ParkingLot::State st = _pl->get_state();
           if (st.stopped()) {
               return false;
           }
           if (steal_task(tid)) {
               return true;
           }
           _pl->wait(st);
   #endif
       } while (true);
   }
   ```
   
   会调用steal_work。
   ```c
       bool steal_task(bthread_t* tid) {
           if (_remote_rq.pop(tid)) {
               return true;
           }
   #ifndef BTHREAD_DONT_SAVE_PARKING_STATE
           _last_pl_state = _pl->get_state();
   #endif
           return _control->steal_task(tid, &_steal_seed, _steal_offset);
       }
   ```
   请问为什么要优先从当前TaskGroup的_remote_rq进行消费,找出任务,而不是_rq。
   
   只有steal(窃取)其他(非当前TaskGroup)TaskGroup的时候,TaskGroup的 _rq才会被消费。
   


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

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