ITADN

Bug: async/barrier might not work as intended

#36OpenhansSchall 创建于 2025-04-01
H
hansSchallcommented
I was discovering the project structure when I came across the Barrier implementation. I already built something similar before and its first version was designed the same way. A while ago I discovered that my first version was not working as intended when code waits for it and immediately locks/pauses it again. In case multiple tasks do this at the same time, all will be run instead of waiting for each other. Most likely your version is also affected. I had to wrap the resume function recursively in `queueMicrotask`, because promises do the same. Have a look at it: https://github.com/deno-plc/deno-plc/blob/main/utils/src/lock.ts and the tests: https://github.com/deno-plc/deno-plc/blob/main/utils/src/lock.test.ts
0 条评论