-
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.
WIP: Add support for domain local await
- Loading branch information
Showing
10 changed files
with
119 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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 b -> Broadcast.resume_all b | ||
| _ -> () | ||
and await () = | ||
if Atomic.get state != `Released then | ||
let b = Broadcast.create () in | ||
if Atomic.compare_and_set state `Init (`Awaiting b) then | ||
let resume ctx enqueue = | ||
match Broadcast.suspend b (fun () -> enqueue (Ok ())) with | ||
| None -> () | ||
| Some request -> ( | ||
match Atomic.get state with | ||
| `Awaiting _ -> | ||
Cancel.Fiber_context.set_cancel_fn ctx @@ fun ex -> | ||
if Broadcast.cancel request then enqueue (Error ex) | ||
| _ -> if Broadcast.cancel request then enqueue (Ok ())) | ||
in | ||
Suspend.enter resume | ||
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