ZhengweiZhu commented on code in PR #3096:
URL: https://github.com/apache/brpc/pull/3096#discussion_r2435012875


##########
src/bthread/task_control.cpp:
##########
@@ -587,4 +587,29 @@ bvar::LatencyRecorder* 
TaskControl::create_exposed_pending_time() {
     return pt;
 }
 
+std::vector<bthread_t> TaskControl::get_living_bthreads() {
+    std::vector<bthread_t> living_bthread_ids;
+    std::vector<TaskMeta*> living_tasks = butil::list_resources<TaskMeta>(

Review Comment:
   > Since `butil::list_resources` accepts a lambda function, I think it don't 
need to return `vector<TaskMeta*>` any more. you can capture the local variable 
`living_bthread_ids` by reference and directly use 
`living_bthread_ids.push_back(m->tid)` in the lambda function.
   
   Yes. It's two different interface. list_resources indicates get all 
resources in resource pool meeting the filter condition, however your proposed 
interface is actually for_each_resource(lamda) to traverse each resource and 
apply some operation. Both way works here if the aim is to get living bthreads. 
I use list_resources interface just like the other interfaces like 
get_resource, address_resource etc.  Which one shall I expose? Or both ?



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