Git Product home page Git Product logo

Comments (5)

Thomasdezeeuw avatar Thomasdezeeuw commented on June 1, 2024

Do you need this for something specifically? Because as far as I'm aware we currently expose types for all support kinds of fds and operations supported by AFD/IOCP (as Mio uses it).

from mio.

h33p avatar h33p commented on June 1, 2024

Primarily, I'd want to be able to wait for readiness of the IOCP outside mio.

There's an idea I'm experimenting with at the moment. I have a completion IO lib that should be able to be plugged into different kinds of executors.

You have a future that issues I/O requests, and a "backend" that processes them. You have 3 options for how the backend is implemented:

  1. Backend itself polls the future to completion - you get a full async executor here.
  2. Backend works on the side as a secondary thread or a blocking task - now you possibly run into thread communication bottlenecks.
  3. Backend exposes a handle that can be then polled for readiness by the parent executor.

I don't have hard numbers, but 3 seems like the most effective solution. On Linux, if you have a io_uring queue, you can plug its fd in a epoll system, or even another io_uring queue, and wait for multiple queues simultaneously.

I'm not so knowledgeable in windows side of things, and from what I saw, while you technically can WaitForSingleObject on a IOCP handle, it's undocumented, unsupported, and doesn't have stable behavior, but I think you can wait for it with GetQueuedCompletionStatus, without removing events from the queue by passing null lpOverlapped (unless I'm misreding the docs). So I thought exposing raw handle to iocp would make sense.

from mio.

h33p avatar h33p commented on June 1, 2024

Okay, no, I'm reading more into this and this is not what I need, and exposing the handle to iocp is potentially dangerous, because the code assumes a valid pointer is an instance of Overlapped. What I think I'd need is ability to set hEvent of OVERLAPPED, and basically having such structure set for everything sent to IOCP.

from mio.

notgull avatar notgull commented on June 1, 2024

It might be worth it to just add an option to wait on a waitable handle to mio.

from mio.

Thomasdezeeuw avatar Thomasdezeeuw commented on June 1, 2024

It might be worth it to just add an option to wait on a waitable handle to mio.

I don't remember the details, but if I remember correctly using the handle directly combined with the way Mio uses is quite difficult to use correctly as @h33p also found out, so I rather not add it with a good use case for it.

from mio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.