http://glfwtfwhlsm2u5pw3b7crist7bt7fwepj2wgv3n3b64unj22v5435tyd.onion/blog/2019/08/09/Simplyfile.html
Add a file descriptor with flags to be monitored, have a thread wait for any file descriptor to become ready and then process it.
The processing part is easily realized by callbacks.