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

Decide and document thread-safety in cross-platform API #387

Closed
Tracked by #388
talex5 opened this issue Dec 12, 2022 · 1 comment · Fixed by #568
Closed
Tracked by #388

Decide and document thread-safety in cross-platform API #387

talex5 opened this issue Dec 12, 2022 · 1 comment · Fixed by #568
Labels
api API design decision
Milestone

Comments

@talex5
Copy link
Collaborator

talex5 commented Dec 12, 2022

Currently, we only say that the synchronisation primitives (promises, etc) can be safely shared between domains. However, we need to allow at least some other things (e.g. the file-system and network) to be shared as otherwise there's no way to use them from other domains. Probably all of Stdenv should be shareable.

For Unix, this may require some fairly heavy-weight reference counting to ensure that we never close a file descriptor while it's being used by another thread (which might include it being queued up in another domain's io_uring queue, for example). Unix is quick to reuse FD numbers once closed, which can easily lead to corrupting an unrelated file.

Also, we should document whether you can do e.g. overlapping writes on a flow. For example, whether this always writes "AB" to the flow f (see e.g. mirleft/ocaml-tls#458):

Fiber.both
  (fun () -> Flow.write f "A")
  (fun () -> Flow.write f "B")
@talex5
Copy link
Collaborator Author

talex5 commented Mar 28, 2023

OS resources can be safely shared now with the eio_linux and eio_posix backends. Once eio_luv is deleted, we can document that this is supported.

@balat balat added this to the Eio 1.0 milestone May 12, 2023
@talex5 talex5 modified the milestones: Eio 1.0, 0.11 Jun 2, 2023
@balat balat modified the milestones: 0.11, Eio 1.0 Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api API design decision
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants