Skip to content

Move Eio.Stdenv.t to Eio_unix.Stdenv.base#498

Merged
talex5 merged 1 commit intoocaml-multicore:mainfrom
talex5:stdenv
May 2, 2023
Merged

Move Eio.Stdenv.t to Eio_unix.Stdenv.base#498
talex5 merged 1 commit intoocaml-multicore:mainfrom
talex5:stdenv

Conversation

@talex5
Copy link
Copy Markdown
Collaborator

@talex5 talex5 commented Apr 30, 2023

The old type wasn't directly useful for anything, since nothing provides exactly this set of resources, and nothing needs to consume exactly this set either. However, it is useful in Eio_unix as the set of resources that a backend needs to provide to be compatible with Eio_main.run.

The new type is almost the same for now, except that the standard streams include file descriptors. Other Unix-specific features can be added later, such as support for passing file descriptors over sockets or to child processes.

I called the type base because we might want to add a Stdenv.linux_or_unix subtype later for basically everything that isn't Windows. Not sure what the name should be, though.

Note that, due to the way row-polymorphism works in OCaml, we can't e.g. have Net.connect return an Eio_unix.socket subtype of Eio.Net.socket. But we can add a new function (e.g. connect_unix) that returns a richer socket type.

@talex5 talex5 added the enhancement New feature or request label Apr 30, 2023
The old type wasn't directly useful for anything, since nothing provides
exactly this set of resources, and nothing needs to consume exactly this
set either. However, it is useful in Eio_unix as the set of resources
that a backend needs to provide to be compatible with `Eio_main.run`.

The new type is almost the same for now, except that the standard
streams include file descriptors. Other Unix-specific features can be
added later, such as support for passing file descriptors over sockets
or to child processes.
@c-cube
Copy link
Copy Markdown
Contributor

c-cube commented Jun 6, 2023

if I want to ask for "classic" permissions that a non-Eio program would have, what should I use now? I started something with 0.9 and exactly one stdenv:Eio.Stdenv.t -> … signature and now I'm a bit lost. I'm not interested in tying it to a particular backend either.

@talex5
Copy link
Copy Markdown
Collaborator Author

talex5 commented Jun 6, 2023

If your program requires a "classic" OS then you can just use Eio_unix.Stdenv.t instead. It will work with any of the classic backends (eio_linux, eio_posix, eio_windows). It won't work with unikernels, but it wouldn't have done with the old Stdenv.t either.

But probably it would be better to list the things your program actually needs. See: https://github.com/ocaml-multicore/eio#passing-env

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants