async_simple icon indicating copy to clipboard operation
async_simple copied to clipboard

Mutex unlock这里为啥是原地resume呀

Open chloro-pn opened this issue 1 year ago • 2 comments

Search before asking

  • [x] I searched the issues and found no similar issues.

What happened + What you expected to happen

Mutex unlock这里为啥是原地resume呀: https://github.com/alibaba/async_simple/blob/main/async_simple/coro/Mutex.h#L134

对于绑定了executor的Lazy是不是交还executor调度比较好

Reproduction way

Anything else

Are you willing to submit a PR?

  • [ ] Yes I am willing to submit a PR!

chloro-pn avatar May 30 '24 06:05 chloro-pn

哦哦知道了,lock是走ViaAsyncAwaiter

chloro-pn avatar May 30 '24 06:05 chloro-pn

这里是有些问题,unlock 时可能在当前线程 resume 太多任务导致卡死。之前也有个 FIXME 说 Mutex 应该实现 Executor

ChuanqiXu9 avatar May 30 '24 07:05 ChuanqiXu9

这里是有些问题,unlock 时可能在当前线程 resume 太多任务导致卡死。之前也有个 FIXME 说 Mutex 应该实现 Executor

假设十万个协程同时抢一个mutex,那么就会不断递归遍历Mutex的coroutine handle链表,很可能导致栈溢出。之前在CI上偶发的见过这个问题。

poor-circle avatar Oct 18 '24 14:10 poor-circle