6 comments

  • emersion36 days ago
    My go-to small event loop library is <a href="https:&#x2F;&#x2F;github.com&#x2F;any1&#x2F;aml" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;any1&#x2F;aml</a>
  • mgaunard36 days ago
    Why not io_uring? That&#x27;s the biggest game changer.<p>I guess because it&#x27;s not possible to abstract away as much.
    • immibis36 days ago
      io_uring works fundamentally differently from polling loops and closer to Windows&#x27; IOCP (which is awesome and better than everything that existed on Linux for many years). With a polling loop you wait for data to be available in buffers, and then once you get the ready event, you copy it from the kernel&#x27;s buffer to yours. With IOCP or io_uring, you submit a long-running read or write event directly into your buffer. You get the event after the read or write call, instead of before. Because of this, it&#x27;s not possible to make it a drop-in replacement for poll&#x2F;epoll.
      • cryptonector36 days ago
        From an abstract API perspective it doesn&#x27;t matter: it&#x27;s just fire-and-forget where you call a function that will start some I&#x2F;O and you associate some sort of event completion notice. The details matter only regarding performance.
        • immibis35 days ago
          For this to work, your API has to be an async I&#x2F;O API not an event listening API. It can&#x27;t be &quot;wait for readable&quot; - it has to be &quot;do a read and wait for it&quot;
          • cryptonector35 days ago
            No, it&#x27;s &quot;launch a read and elsewhere get a completion event&quot;.<p>&quot;do a read and wait for it&quot; is synchronous I&#x2F;O.
      • pengaru36 days ago
        didn&#x27;t prevent libuv from adding support for it when available:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;libuv&#x2F;libuv&#x2F;issues&#x2F;1947" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;libuv&#x2F;libuv&#x2F;issues&#x2F;1947</a>
        • manwe15036 days ago
          libuv is more nearly designed for adding IOCP-like support to epoll systems than epoll to IOCP (though it can approximate either direction), so adding io_uring was already straightforward, by design<p>Aside: the wepoll mentioned in this repo is a standalone project extracted libuv, for projects that only desire to support Berkeley sockets and don’t care about other events sources (processes or pipes)
    • foobarian36 days ago
      Is this a Windows lib? The tradeoffs are probably completely different than what we&#x27;re used to then.<p>&gt; c-events provides function wrappers to some Linux like functionality, exp. mkfifo for Windows.
  • kevin_thibedeau36 days ago
    <p><pre><code> void *rwtask(param_t v) { ... a = v-&gt;int_ptr; ... free(a); </code></pre> It seems architecturally unwise to have a callback responsible for freeing its parameters. At the very least this fossilizes dependency on the stdlib heap.
    • tom_36 days ago
      I think it makes sense to leave freeing up to the callback, because then management of the object (whatever it is) is up to the caller rather than the library. It might make sense to reuse it for a subsequent request (one way or another), or have it as part of some larger object, or some other thing - etc.<p>As for using the stdlib heap rather than some other thing: sure. But the routine allocating the buffer in this case used malloc to allocate it, and therefore freeing it with free seems at least not the worst option. If you want to do some other thing, you should do that instead.
  • lukaslalinsky35 days ago
    I was super interested in the non-assembly coroutine approach, as I&#x27;m working on a similar project for Zig, but it turns out it just embeds x86_64 binary. Why is that better than having assembly there?
  • miguel_martin36 days ago
    See also: Nim&#x27;s std&#x2F;selectors API - <a href="https:&#x2F;&#x2F;nim-lang.org&#x2F;docs&#x2F;selectors.html" rel="nofollow">https:&#x2F;&#x2F;nim-lang.org&#x2F;docs&#x2F;selectors.html</a>, it supports: &quot;Supported features: files, sockets, pipes, timers, processes, signals and user events.&quot; - here&#x27;s a HTTP server event loop using it: <a href="https:&#x2F;&#x2F;github.com&#x2F;guzba&#x2F;mummy&#x2F;blob&#x2F;master&#x2F;src&#x2F;mummy.nim#L1132" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;guzba&#x2F;mummy&#x2F;blob&#x2F;master&#x2F;src&#x2F;mummy.nim#L11...</a>
  • cryptonector36 days ago
    Nice! I could use this :) (for open source work).<p>Though I would prefer to have something not based on coroutines.