Closed YiraSan closed 2 weeks ago
Did you look at https://github.com/Cloudef/zig-aio/blob/master/src/coro/Sync.zig ?
Right, I totally missed that one ! There's still a need for a RwLock implementation, this being pretty simple to do, I will probably PR this week for it.
I've been using zig-aio for the past weeks, and I would say that the only thing missing right now is an async mutex, instead of blocking the coroutine, it would be nice to have an asynchronous mutex, and a rwlock deriving from it.
I've multiple idea on how to implement it, but since I did not read enough the source code of zig-aio I can't really directly pull request. I first thought of a basic aio.Mutex, that would use inside a std.Thread.Mutex, but only doing tryLock() then it would either do a aio.Timeout(1ns or so), or directly complete a pending coroutine then check again tryLock until the lock is finally acquirable.
What do you think of that idea ? Is it a better way to implement an asynchronous mutex ?