Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create scheduler friendly FS module #21

Open
leostera opened this issue Dec 22, 2023 · 0 comments
Open

Create scheduler friendly FS module #21

leostera opened this issue Dec 22, 2023 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@leostera
Copy link
Collaborator

Would be useful to have a little File module to read/write files in a scheduler-friendly way.

In short, we would need a module like Net.Socket with functions like:

  • File.open file that returns a Fd.t
  • File.read fil that return an (Bigstringaf.t, _) result
  • File.write file ~data

Internally these functions can call the I/O module to do the actual reading/writing, they just have to beware that if the I/O module says `Retry then you have to call syscall "debugging-name" fd @@ fun fd -> (* do work here *) like this:

let rec read fd ~buf =
  match IO.read fd buf with
  | `Retry -> syscall "file.read" `r fd @@ read ~buf
  (* ... *)

This way we would tell the scheduler we're waiting, and some other process can run.

@leostera leostera added enhancement New feature or request help wanted Extra attention is needed labels Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant