Comment by mort96

Comment by mort96 a day ago

9 replies

I wish the UNIXes had gone together and standardized a modern alternative to poll, maybe as part of POSIX. It sucks that any time I want to listen to IO events, I have to choose between old, low performance, cross-platform APIs and the new, higher-performance but Linux-only epoll.

ninjin a day ago

Which is why there is libevent [1]?

[1]: https://libevent.org

Unless I am mistaken, OpenBSD base even explicitly codes against the older libevent API internally and ships it with each release, despite at the very least supporting kqueue, and thus gains better portability for a number of their tools this way.

Personally, I just go with Posix select for small programs where performance is not critical anyway.

  • eqvinox a day ago

    There are a whole bunch of these — libevent, libev, glib's main loop, Qt's main loop, Apache's modular event loop, …

    …which is why there is libverto, a 2nd order abstraction.

    It'd be funny if it weren't also sad.

usrnm a day ago

Aren't there enough wrapper libraries for all programming languages that take care of this under the hood? You don't have to rely on libc only

  • mort96 a day ago

    Sure, there are wrapper libraries. But then I'm met with the question: do I add some big heavy handed IO wrapper library, or ... do I just call poll

    • Galanwe a day ago

      I wouldn't count uv/ev/etc as "big heavy IO wrapper library".

      • mort96 a day ago

        I would, especially when nothing else in the program uses it and you just introduce it for one small thing in place of calling poll(). It's over 40 000 loc, over 70 000 including tests.

ahartmetz a day ago

For sure. Though every platform does have it own high-performance alternative, with only kqueue shared by some less popular ones.