libxev is a cross-platform, high-performance event loop that provides abstractions for non-blocking IO, timers, events, and more and works on Linux (io_uring or epoll), macOS (kqueue), and Wasm + WASI. Available as both a Zig and C API.
by mitchellh2 of 6 standards met
This fixes some behavior I observed using libxev on macOS. Setting a timer fires before the expected time, apparently because uses the existing cached time (). If that cached time is outdated because of a long wait, the timer will fire almost immediately rather than after the desired time. I've included a test which fails on that shows this behavior. This test delays loop wakeup, arms a timer from the callback, and asserts elapsed time is at least . The timer API describes as βfrom nowβ, so scheduling should use current loop time, not the potentially stale cached time. I looked through the existing issues and PRs and didn't see this referenced, so I'm not sure if this in fact expected behavior. If it is, am I misunderstanding the behavior of the timer API on Kqueue? This is solved in the backend with this line: https://github.com/mitchellh/libxev/blob/78781eef639f9eb9935b067b4bbc1e69254bda3d/src/backend/io_uring.zig#L337 which updates the cached time if we're . For simplicity, I opted to not add this flag and unconditionally update the cached time on Kqueue.
Repository: mitchellh/libxev. Description: libxev is a cross-platform, high-performance event loop that provides abstractions for non-blocking IO, timers, events, and more and works on Linux (io_uring or epoll), macOS (kqueue), and Wasm + WASI. Available as both a Zig and C API. Stars: 3356, Forks: 155. Primary language: Zig. Languages: Zig (97.8%), CSS (0.9%), C++ (0.6%), Nix (0.4%), JavaScript (0.1%). License: MIT. Topics: async, c, epoll, io-uring, kqueue, wasi, webassembly, zig. Open PRs: 12, open issues: 31. Last activity: 6d ago. Community health: 42%. Top contributors: mitchellh, dependabot[bot], Corendos, charlesrocket, ianic, steeve, recursiveGecko, linuxy, kcbanner, rockorager and others.
Zig
Last 12 weeks Β· 16 commits
https://github.com/mitchellh/libxev/pull/195/changes/71754f7223c1ebe068ce931a6cd067d793aa0697