Skip to content

Commit

Permalink
refactor: move optional hmap FLS stuff into core/task_local_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Aug 30, 2024
1 parent 328ecf4 commit fd11e1c
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 70 deletions.
5 changes: 5 additions & 0 deletions src/core/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
(libraries
moonpool.private
(re_export thread-local-storage)
(select
hmap_ls_.ml
from
(hmap -> hmap_ls_.real.ml)
(-> hmap_ls_.dummy.ml))
moonpool.dpool
(re_export exn_bt)
(re_export picos))
Expand Down
2 changes: 2 additions & 0 deletions src/core/task_local_storage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ let with_value k v (f : _ -> 'b) : 'b =
PF.FLS.set fiber k v;
let finally () = PF.FLS.set fiber k old_v in
Fun.protect f ~finally

include Hmap_ls_
8 changes: 8 additions & 0 deletions src/core/task_local_storage.mli
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ val with_value : 'a t -> 'a -> (unit -> 'b) -> 'b
(** [with_value k v f] sets [k] to [v] for the duration of the call
to [f()]. When [f()] returns (or fails), [k] is restored
to its old value. *)

(** {2 Local [Hmap.t]}
This requires [hmap] to be installed. *)

include module type of struct
include Hmap_ls_
end
7 changes: 1 addition & 6 deletions src/fib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
(synopsis "Fibers and structured concurrency for Moonpool")
(libraries
moonpool
picos
(select
hmap_fls.ml
from
(hmap -> hmap_fls.real.ml)
(-> hmap_fls.dummy.ml)))
picos)
(enabled_if
(>= %{ocaml_version} 5.0))
(flags :standard -open Moonpool_private -open Moonpool)
Expand Down
2 changes: 1 addition & 1 deletion src/fib/fiber.ml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ let spawn_ ~parent ~runner (f : unit -> 'a) : 'a t =

(* copy local hmap from parent, if present *)
Option.iter
(fun (p : _ t) -> Hmap_fls.Private_hmap_fls_.copy_fls p.pfiber pfiber)
(fun (p : _ t) -> Fls.Private_hmap_ls_.copy_fls p.pfiber pfiber)
parent;

(match parent with
Expand Down
1 change: 0 additions & 1 deletion src/fib/fls.ml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
include Task_local_storage
include Hmap_fls
8 changes: 0 additions & 8 deletions src/fib/fls.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,3 @@
include module type of struct
include Task_local_storage
end

(** {2 Local [Hmap.t]}
This requires [hmap] to be installed. *)

include module type of struct
include Hmap_fls
end
7 changes: 0 additions & 7 deletions src/fib/hmap_fls.dummy.ml

This file was deleted.

47 changes: 0 additions & 47 deletions src/fib/hmap_fls.real.ml

This file was deleted.

0 comments on commit fd11e1c

Please sign in to comment.