-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from anuragsoni/conditional-compilation-for-5…
…00-4-14 Get core compiling with OCaml 5.0
- Loading branch information
Showing
7 changed files
with
172 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1 @@ | ||
open! Import | ||
open Std_internal | ||
module Ephemeron = Caml.Ephemeron.K1 | ||
|
||
type ('a, 'b) t = ('a Heap_block.t, 'b Heap_block.t) Ephemeron.t | ||
|
||
let create = Ephemeron.create | ||
|
||
let set_key t = function | ||
| None -> Ephemeron.unset_key t | ||
| Some v -> Ephemeron.set_key t v | ||
;; | ||
|
||
let get_key = Ephemeron.get_key | ||
|
||
let set_data t = function | ||
| None -> Ephemeron.unset_data t | ||
| Some v -> Ephemeron.set_data t v | ||
;; | ||
|
||
let get_data = Ephemeron.get_data | ||
let is_key_some t = Ephemeron.check_key t | ||
let is_key_none t = not (is_key_some t) | ||
let is_data_some t = Ephemeron.check_data t | ||
let is_data_none t = not (is_data_some t) | ||
|
||
let sexp_of_t sexp_of_a sexp_of_b t = | ||
[%sexp_of: a Heap_block.t option * b Heap_block.t option] (get_key t, get_data t) | ||
;; | ||
include Caml.Ephemeron |
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,26 +1 @@ | ||
(** An ephemeron is a pair of pointers, one to a "key" and one to "data". | ||
The key pointer is a weak pointer: the garbage collector doesn't follow it when | ||
determining liveness. The garbage collector follows an ephemeron's data pointer iff | ||
the key is alive. If the garbage collector nulls an ephemeron's weak pointer then it | ||
also nulls the data pointer. Ephemerons are more powerful than weak pointers because | ||
they express conjunction of liveness -- the data in an ephemeron is live iff both the | ||
key {e and} the ephemeron are live. See "Ephemerons: A New Finalization Mechanism", | ||
Barry Hayes 1997. | ||
This module is like the OCaml standard library module [Ephemerons.K1], except that it | ||
requires that the keys and data are heap blocks. *) | ||
|
||
open! Import | ||
|
||
type ('a, 'b) t [@@deriving sexp_of] | ||
|
||
val create : unit -> _ t | ||
val set_key : ('a, _) t -> 'a Heap_block.t option -> unit | ||
val get_key : ('a, _) t -> 'a Heap_block.t option | ||
val set_data : (_, 'b) t -> 'b Heap_block.t option -> unit | ||
val get_data : (_, 'b) t -> 'b Heap_block.t option | ||
val is_key_some : _ t -> bool | ||
val is_key_none : _ t -> bool | ||
val is_data_some : _ t -> bool | ||
val is_data_none : _ t -> bool | ||
include module type of Caml.Ephemeron |
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