This is an automated email from the ASF dual-hosted git repository.

wwbmmm pushed a commit to branch release-1.14
in repository https://gitbox.apache.org/repos/asf/brpc.git

commit 3c406460016a6a3ca1117fe539872233f8439c9c
Author: Yang,Liming <liming.y...@139.com>
AuthorDate: Sun Jul 27 00:40:17 2025 +0800

    add flags for set worker thread name (#3037)
---
 src/bthread/task_control.cpp | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/bthread/task_control.cpp b/src/bthread/task_control.cpp
index 94be504f..0cc3754a 100644
--- a/src/bthread/task_control.cpp
+++ b/src/bthread/task_control.cpp
@@ -38,9 +38,9 @@ DEFINE_int32(task_group_delete_delay, 1,
              "delay deletion of TaskGroup for so many seconds");
 DEFINE_int32(task_group_runqueue_capacity, 4096,
              "capacity of runqueue in each TaskGroup");
-DEFINE_int32(task_group_yield_before_idle, 0,
-             "TaskGroup yields so many times before idle");
 DEFINE_int32(task_group_ntags, 1, "TaskGroup will be grouped by number ntags");
+DEFINE_bool(task_group_set_worker_name, true,
+            "Whether to set the name of the worker thread");
 
 namespace bthread {
 
@@ -92,10 +92,12 @@ void* TaskControl::worker_thread(void* arg) {
 
     g->_tid = syscall(SYS_gettid);
 
-    std::string worker_thread_name = butil::string_printf(
-        "brpc_wkr:%d-%d", g->tag(),
-        c->_next_worker_id.fetch_add(1, butil::memory_order_relaxed));
-    butil::PlatformThread::SetName(worker_thread_name.c_str());
+    if (FLAGS_task_group_set_worker_name) {
+        std::string worker_thread_name = butil::string_printf(
+            "brpc_wkr:%d-%d", g->tag(),
+            c->_next_worker_id.fetch_add(1, butil::memory_order_relaxed));
+        butil::PlatformThread::SetName(worker_thread_name.c_str());
+    }
     BT_VLOG << "Created worker=" << pthread_self() << " tid=" << g->_tid
             << " bthread=" << g->main_tid() << " tag=" << g->tag();
     tls_task_group = g;


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to