-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Thomas Leonard <[email protected]>
- Loading branch information
Showing
11 changed files
with
117 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
let prepare_for_await () = | ||
let state = Atomic.make `Init in | ||
let release () = | ||
if Atomic.get state != `Released then | ||
match Atomic.exchange state `Released with | ||
| `Awaiting enqueue -> enqueue (Ok ()) | ||
| _ -> () | ||
and await () = | ||
if Atomic.get state != `Released then | ||
Suspend.enter @@ fun ctx enqueue -> | ||
let awaiting = `Awaiting enqueue in | ||
if Atomic.compare_and_set state `Init awaiting then ( | ||
Cancel.Fiber_context.set_cancel_fn ctx (fun ex -> | ||
if Atomic.compare_and_set state awaiting `Released then ( | ||
enqueue (Error ex) | ||
) | ||
) | ||
) else ( | ||
enqueue (Ok ()) | ||
) | ||
in | ||
Domain_local_await.{ release; await } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(library | ||
(name eio__core) | ||
(public_name eio.core) | ||
(libraries cstruct hmap lwt-dllist fmt optint)) | ||
(libraries cstruct hmap lwt-dllist fmt optint domain-local-await)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,6 @@ module Private = struct | |
| Fork = Fiber.Fork | ||
| Get_context = Cancel.Get_context | ||
end | ||
|
||
module Dla = Dla | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters