forked from ocaml/dune
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: disallow multiple build commands (ocaml#6360)
Running dune concurrently is no longer allowed because we create the rpc socket file eagerly and treat it as a lock Signed-off-by: Rudi Grinberg <[email protected]>
- Loading branch information
Showing
27 changed files
with
558 additions
and
66 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
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
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,49 @@ | ||
open Import | ||
open Fiber.O | ||
|
||
type server = | ||
{ run : unit Fiber.t | ||
; stop : unit Fiber.t | ||
; ready : unit Fiber.t | ||
} | ||
|
||
type t = | ||
{ server : server | ||
; pool : Fiber.Pool.t | ||
; mutable state : [ `Awaiting_start | `Running | `Stopped ] | ||
} | ||
|
||
let t = Fiber.Var.create () | ||
|
||
let stop ({ state; server; pool } as t) = | ||
let* () = Fiber.return () in | ||
match state with | ||
| `Stopped -> Fiber.return () | ||
| `Awaiting_start -> Fiber.Pool.stop pool | ||
| `Running -> | ||
t.state <- `Stopped; | ||
Fiber.fork_and_join_unit | ||
(fun () -> Fiber.Pool.stop pool) | ||
(fun () -> server.stop) | ||
|
||
let with_background_rpc server f = | ||
let pool = Fiber.Pool.create () in | ||
let v = { state = `Awaiting_start; server; pool } in | ||
Fiber.Var.set t v (fun () -> | ||
Fiber.fork_and_join_unit | ||
(fun () -> Fiber.Pool.run pool) | ||
(fun () -> Fiber.finalize f ~finally:(fun () -> stop v))) | ||
|
||
let ensure_ready () = | ||
let* ({ state; server; pool } as t) = Fiber.Var.get_exn t in | ||
match state with | ||
| `Stopped -> Code_error.raise "server already stopped" [] | ||
| `Running -> Fiber.return () | ||
| `Awaiting_start -> | ||
t.state <- `Running; | ||
let* () = Fiber.Pool.task pool ~f:(fun () -> server.run) in | ||
server.ready | ||
|
||
let stop () = | ||
let* t = Fiber.Var.get_exn t in | ||
stop t |
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,11 @@ | ||
type server = | ||
{ run : unit Fiber.t | ||
; stop : unit Fiber.t | ||
; ready : unit Fiber.t | ||
} | ||
|
||
val with_background_rpc : server -> (unit -> 'a Fiber.t) -> 'a Fiber.t | ||
|
||
val ensure_ready : unit -> unit Fiber.t | ||
|
||
val stop : unit -> unit Fiber.t |
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
Oops, something went wrong.