Get the latest tech news
The missing cross-platform OS API for timers
ublished on 2025-02-02 Discussions: /r/programming Most serious programs will need to trigger some action at a delayed point in time, often repeatedly: set timeouts, clean up temporary files or entries in the database, send keep-alives, garbage-collect unused entities, etc. All while doing some work in the meantime.
Table of contents Most serious programs will need to trigger some action at a delayed point in time, often repeatedly: set timeouts, clean up temporary files or entries in the database, send keep-alives, garbage-collect unused entities, etc. Lately, I have found myself in need of doing just that, repeatedly sending a keep-alive over the network to many remote peers, in C. My program has an event loop, a la NodeJS or Redis. That means that using the venerable poll(2), we can wait on an array of very diverse things: sockets, files, signals, timers, processes, pipes, etc.
Or read this on Hacker News