Cloudef / zig-aio

io_uring like asynchronous API and coroutine powered IO tasks for zig
https://cloudef.github.io/zig-aio/
MIT License
172 stars 8 forks source link

Condition implementation #13

Open bigs opened 1 month ago

bigs commented 1 month ago

Would you be interested in an implementation of Conditionals in Sync.zig? I'm working on a toy project with zig-aio and could really use a Conditional in the style of pthreads. Functionally, it'd be pretty similar to the ResetEvent, but signaling the Condition only awakens a single waiter from a wait queue.

From looking around the codebase, I'd have to add a WaitQueue type to Frame (doubly linked list) and a corresponding link attribute to the Frame. Otherwise, it would just be a new struct in Sync.zig.

bigs commented 1 month ago

I've actually hacked something together, so I'll throw up a PR you can take a look at. I noticed there are no tests for Sync, I'll add some of those too if it's easy enough.