wwbmmm commented on code in PR #1751:
URL: https://github.com/apache/incubator-brpc/pull/1751#discussion_r867582179
##########
src/bthread/task_group_inl.h:
##########
@@ -46,10 +46,10 @@ inline TaskMeta* TaskGroup::address_meta(bthread_t tid) {
return address_resource(get_slot(tid));
}
-inline void TaskGroup::exchange(TaskGroup** pg, bthread_t next_tid) {
+inline void TaskGroup::exchange(TaskGroup** pg, bthread_t next_tid, bool
nosignal) {
TaskGroup* g = *pg;
if (g->is_current_pthread_task()) {
- return g->ready_to_run(next_tid);
+ return g->ready_to_run(next_tid, nosignal);
}
ReadyToRunArgs args = { g->current_tid(), false };
Review Comment:
这个false要改成nosignal
##########
src/bthread/butex.cpp:
##########
@@ -335,13 +348,20 @@ int butex_wake_all(void* arg) {
g->ready_to_run_general(w->tid, true);
++nwakeup;
}
- if (saved_nwakeup != nwakeup) {
+ if (nosignal) {
+ if (!tls_task_group) {
+ tls_task_group_nosignal = g;
Review Comment:
这个移到get_task_group逻辑里,参考上面评论
##########
src/bthread/butex.cpp:
##########
@@ -281,14 +282,24 @@ int butex_wake(void* arg) {
unsleep_if_necessary(bbw, get_global_timer_thread());
TaskGroup* g = tls_task_group;
if (g) {
- TaskGroup::exchange(&g, bbw->tid);
+ if (!nosched) {
+ TaskGroup::exchange(&g, bbw->tid, nosignal);
+ } else {
+ g->ready_to_run_general(bbw->tid, nosignal);
+ }
} else {
- bbw->control->choose_one_group()->ready_to_run_remote(bbw->tid);
+ bbw->control->choose_one_group()->ready_to_run_remote(bbw->tid,
nosignal);
Review Comment:
参考start_from_non_worker的逻辑,这里应该类似于
```cpp
if (nosignal) {
g = tls_task_group_nosignal;
if (NULL == g) {
g = c->choose_one_group();
tls_task_group_nosignal = g;
}
} else {
g = c->choose_one_group();
}
g->ready_to_run_remote(bbw->tid, nosignal);
```
可以考虑给get_task_group函数加个nosignal参数,把这段逻辑封装到里面
##########
src/bthread/butex.cpp:
##########
@@ -319,11 +330,13 @@ int butex_wake_all(void* arg) {
return nwakeup;
}
// We will exchange with first waiter in the end.
- ButexBthreadWaiter* next = static_cast<ButexBthreadWaiter*>(
- bthread_waiters.head()->value());
- next->RemoveFromList();
- unsleep_if_necessary(next, get_global_timer_thread());
- ++nwakeup;
+ ButexBthreadWaiter* next =
+ static_cast<ButexBthreadWaiter*>(bthread_waiters.head()->value());
+ if (!nosched) {
+ next->RemoveFromList();
+ unsleep_if_necessary(next, get_global_timer_thread());
+ ++nwakeup;
+ }
TaskGroup* g = get_task_group(next->control);
Review Comment:
get_task_group增加nosignal参数,参考上面评论
--
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]