#Porting Reactor to 0.16.x std.io - move to Proactor?

1 messages · Page 1 of 1 (latest)

trim laurel
#

moving my project from 0.15.2 to 0.16.x.

old code uses a reactor pattern:

  • dedicated i/o thread.
  • non-blocking sockets.
  • big poll loop.
  • linux only.

I want to support linux (epoll/io_uring), windows (iocp), and macos (kqueue).
my current flow is one io thread with a number of "client" threads.

Questions:

  1. does the new std.io allow implementing a reactor-style loop?
  2. is it possible to run a single-threaded proactor in 0.16.x?
  3. does 0.16.x force moving the whole architecture to proactor?
  4. what is the idiomatic way to implement this?
west compass
#

does the new std.io allow implementing a reactor-style loop?
yes

is it possible to run a single-threaded proactor in 0.16.x?
The details will be hidden by the interface, what you'd do is run the read/write through async then you either await or cancel it, which will block until complete.

you cant seem to check if its finished without waiting. so its not really proactive.

trim laurel
west compass
#

no, you get to chose the implementation, infact the only working one atm is Threaded.
even if you did choose a proactive one, that detail isnt visible when using it.

trim laurel
#

question i asked also on ziggit:

does new io support single-threaded readiness/completion based event loop and hides os staff (epoll/iocp/kqueue) ?

trim laurel
west compass
#

yes but the event loop would be apart of the Io implementation

#

fyi: the wip Evented implementation will use green threads, even if there is a single OS thread

trim laurel
#

looks like single-threaded mode still requires "manual"flush ' work

west compass
#

no, you just have to participate by using async.