Module Ephemeron.K1

Contents

Instructions: Use this module in your project

In the IDE (CLion, Visual Studio Code, Xcode, etc.) you use for your DkSDK project:

  1. Add the following to your project's dependencies/CMakeLists.txt:

    Copy
    DkSDKProject_DeclareAvailable(ocaml
        CONSTRAINT "= 4.14.0"
        FINDLIBS str unix runtime_events threads dynlink)
    DkSDKProject_MakeAvailable(ocaml)
  2. Add the Findlib::ocaml library to any desired targets in src/*/CMakeLists.txt:

    Copy
    target_link_libraries(YourPackage_YourLibraryName
         # ... existing libraries, if any ...
         Findlib::ocaml)
  3. Click your IDE's Build button

Not using DkSDK?

FIRST, do one or all of the following:

  1. Run:

    Copy
    opam install ocaml.4.14.0
  2. Edit your dune-project and add:

    Copy
    (package
      (name YourExistingPackage)
      (depends
      ; ... existing dependenices ...
      (ocaml (>= 4.14.0))))

    Then run:

    Copy
    dune build *.opam # if this fails, run: dune build
  3. Edit your <package>.opam file and add:

    Copy
    depends: [
      # ... existing dependencies ...
      "ocaml" {>= "4.14.0"}
    ]

    Then run:

    Copy
    opam install . --deps-only

FINALLY, add the library to any desired (library)and/or (executable) targets in your **/dune files:

Copy
(library
  (name YourLibrary)
  ; ... existing library options ...
  (libraries
    ; ... existing libraries ...
    ))

(executable
  (name YourExecutable)
  ; ... existing executable options ...
  (libraries
    ; ... existing libraries ...
    ))
type ``('k, 'd) t

an ephemeron with one key

valcreate : ``unit-> ``('k, 'd)`` t

Ephemeron.K1.create () creates an ephemeron with one key. The data and the key are empty

  • alert old_ephemeron_api This function won't be available in 5.0
val get_key : ``('k, 'd)`` t -> 'k option

Ephemeron.K1.get_key eph returns None if the key of eph is empty, Some x (where x is the key) if it is full.

  • alert old_ephemeron_api This function won't be available in 5.0
val get_key_copy : ``('k, 'd)`` t -> 'k option

Ephemeron.K1.get_key_copy eph returns None if the key of eph is empty, Some x (where x is a (shallow) copy of the key) if it is full. This function has the same GC friendliness as Weak.get_copy

If the element is a custom block it is not copied.

  • alert old_ephemeron_api This function won't be available in 5.0
val set_key : ``('k, 'd)`` t -> 'k -> unit

Ephemeron.K1.set_key eph el sets the key of eph to be a (full) key to el

  • alert old_ephemeron_api This function won't be available in 5.0
val unset_key : ``('k, 'd)`` t -> unit

Ephemeron.K1.unset_key eph el sets the key of eph to be an empty key. Since there is only one key, the ephemeron starts behaving like a reference on the data.

  • alert old_ephemeron_api This function won't be available in 5.0
val check_key : ``('k, 'd)`` t -> bool

Ephemeron.K1.check_key eph returns true if the key of the eph is full, false if it is empty. Note that even if Ephemeron.K1.check_key eph returns true, a subsequent Ephemeron.K1.get_keyeph can return None.

  • alert old_ephemeron_api This function won't be available in 5.0
val blit_key : ``('k, _)`` t -> ``('k, _)`` t -> unit

Ephemeron.K1.blit_key eph1 eph2 sets the key of eph2 with the key of eph1. Contrary to using Ephemeron.K1.get_key followed by Ephemeron.K1.set_key or Ephemeron.K1.unset_key this function does not prevent the incremental GC from erasing the value in its current cycle.

  • alert old_ephemeron_api This function won't be available in 5.0
val get_data : ``('k, 'd)`` t -> 'd option

Ephemeron.K1.get_data eph returns None if the data of eph is empty, Some x (where x is the data) if it is full.

  • alert old_ephemeron_api This function won't be available in 5.0
val get_data_copy : ``('k, 'd)`` t -> 'd option

Ephemeron.K1.get_data_copy eph returns None if the data of eph is empty, Some x (where x is a (shallow) copy of the data) if it is full. This function has the same GC friendliness as Weak.get_copy

If the element is a custom block it is not copied.

  • alert old_ephemeron_api This function won't be available in 5.0
val set_data : ``('k, 'd)`` t -> 'd -> unit

Ephemeron.K1.set_data eph el sets the data of eph to be a (full) data to el

  • alert old_ephemeron_api This function won't be available in 5.0
val unset_data : ``('k, 'd)`` t -> unit

Ephemeron.K1.unset_data eph el sets the key of eph to be an empty key. The ephemeron starts behaving like a weak pointer.

  • alert old_ephemeron_api This function won't be available in 5.0
val check_data : ``('k, 'd)`` t -> bool

Ephemeron.K1.check_data eph returns true if the data of the eph is full, false if it is empty. Note that even if Ephemeron.K1.check_data eph returns true, a subsequent Ephemeron.K1.get_dataeph can return None.

  • alert old_ephemeron_api This function won't be available in 5.0
val blit_data : ``(_, 'd)`` t -> ``(_, 'd)`` t -> unit

Ephemeron.K1.blit_data eph1 eph2 sets the data of eph2 with the data of eph1. Contrary to using Ephemeron.K1.get_data followed by Ephemeron.K1.set_data or Ephemeron.K1.unset_data this function does not prevent the incremental GC from erasing the value in its current cycle.

  • alert old_ephemeron_api This function won't be available in 5.0
valmake :'k -> 'd -> ``('k, 'd)`` t

Ephemeron.K1.make k d creates an ephemeron with key k and data d.

val query : ``('k, 'd)`` t -> 'k -> 'd option

Ephemeron.K1.query eph key returns Some x (where x is the ephemeron's data) if key is physically equal to eph's key, and None if eph is empty or key is not equal to eph's key.

module Make (H:Hashtbl.HashedType) : S with type key=H.t

Functor building an implementation of a weak hash table

Functor building an implementation of a weak hash table. The seed is similar to the one of Hashtbl.MakeSeeded.

module Bucket:sig...end

More from the DkSDK Book

    1. DkSDK
      1. Package capnp
        1. Module Capnp
          1. Module Capnp.Array
          1. Module Capnp.BytesStorage
          1. Module Capnp.Codecs
          1. Module Capnp.Message
          1. Module Capnp.MessageSig
          1. Module Capnp.RPC
          1. Module Capnp.Runtime
        1. Module Capnp_unix
          1. Module Capnp_unix.IO
      1. Package cmdliner
        1. Module Cmdliner
          1. Module Cmdliner.Arg
          1. Module Cmdliner.Cmd
          1. Module Cmdliner.Manpage
          1. Module Cmdliner.Term
        1. Module Cmdliner_arg
        1. Module Cmdliner_base
        1. Module Cmdliner_cline
        1. Module Cmdliner_cmd
        1. Module Cmdliner_docgen
        1. Module Cmdliner_eval
        1. Module Cmdliner_info
          1. Module Cmdliner_info.Arg
          1. Module Cmdliner_info.Cmd
          1. Module Cmdliner_info.Env
          1. Module Cmdliner_info.Eval
          1. Module Cmdliner_info.Exit
        1. Module Cmdliner_manpage
        1. Module Cmdliner_msg
        1. Module Cmdliner_term
        1. Module Cmdliner_term_deprecated
        1. Module Cmdliner_trie
      1. Package fmt
        1. Module Fmt
          1. Module Fmt.Dump
        1. Module Fmt_cli
        1. Module Fmt_tty
      1. Package logs
        1. Module Logs
        1. Module Logs_cli
        1. Module Logs_fmt
        1. Module Logs_lwt
        1. Module Logs_threaded
      1. Package lwt
        1. Module Lwt
          1. Module Lwt.Infix
          1. Module Lwt.Let_syntax
          1. Module Lwt.Syntax
        1. Module Lwt_bytes
        1. Module Lwt_condition
        1. Module Lwt_config
        1. Module Lwt_engine
          1. Module Lwt_engine.Ev_backend
          1. Module Lwt_engine.Versioned
        1. Module Lwt_features
        1. Module Lwt_fmt
        1. Module Lwt_gc
        1. Module Lwt_io
          1. Module Lwt_io.BE
          1. Module Lwt_io.LE
          1. Module Lwt_io.Versioned
        1. Module Lwt_list
        1. Module Lwt_main
          1. Module Lwt_main.Enter_iter_hooks
          1. Module Lwt_main.Exit_hooks
          1. Module Lwt_main.Leave_iter_hooks
        1. Module Lwt_mutex
        1. Module Lwt_mvar
        1. Module Lwt_pool
        1. Module Lwt_pqueue
          1. Module Lwt_pqueue.Make
        1. Module Lwt_preemptive
        1. Module Lwt_process
        1. Module Lwt_result
          1. Module Lwt_result.Infix
          1. Module Lwt_result.Let_syntax
          1. Module Lwt_result.Syntax
        1. Module Lwt_seq
        1. Module Lwt_sequence
        1. Module Lwt_stream
        1. Module Lwt_switch
        1. Module Lwt_sys
        1. Module Lwt_throttle
          1. Module Lwt_throttle.Make
        1. Module Lwt_timeout
        1. Module Lwt_unix
          1. Module Lwt_unix.IO_vectors
          1. Module Lwt_unix.LargeFile
          1. Module Lwt_unix.Versioned
      1. Package mtime
        1. Module Mtime
          1. Module Mtime.Span
        1. Module Mtime_clock
      1. Package ocaml
        1. Module Bigarray
        1. Module Condition
        1. Module Dynlink
        1. Module Event
        1. Module Mutex
        1. Module Profiling
        1. Module Semaphore
          1. Module Semaphore.Binary
          1. Module Semaphore.Counting
        1. Module Stdlib
          1. Module Stdlib.Arg
          1. Module Stdlib.Array
          1. Module Stdlib.ArrayLabels
          1. Module Stdlib.Atomic
          1. Module Stdlib.Bigarray
          1. Module Stdlib.Bool
          1. Module Stdlib.Buffer
          1. Module Stdlib.Bytes
          1. Module Stdlib.BytesLabels
          1. Module Stdlib.Callback
          1. Module Stdlib.Char
          1. Module Stdlib.Complex
          1. Module Stdlib.Digest
          1. Module Stdlib.Either
          1. Module Stdlib.Ephemeron
            1. ...
            1. Module Ephemeron.K1
              1. Module K1.Bucket
              1. Module K1.Make
              1. Module K1.MakeSeeded
          1. Module Stdlib.Filename
          1. Module Stdlib.Float
          1. Module Stdlib.Format
          1. Module Stdlib.Fun
          1. Module Stdlib.Gc
          1. Module Stdlib.Genlex
          1. Module Stdlib.Hashtbl
          1. Module Stdlib.In_channel
          1. Module Stdlib.Int
          1. Module Stdlib.Int32
          1. Module Stdlib.Int64
          1. Module Stdlib.LargeFile
          1. Module Stdlib.Lazy
          1. Module Stdlib.Lexing
          1. Module Stdlib.List
          1. Module Stdlib.ListLabels
          1. Module Stdlib.Map
          1. Module Stdlib.Marshal
          1. Module Stdlib.MoreLabels
          1. Module Stdlib.Nativeint
          1. Module Stdlib.Obj
          1. Module Stdlib.Oo
          1. Module Stdlib.Option
          1. Module Stdlib.Out_channel
          1. Module Stdlib.Parsing
          1. Module Stdlib.Pervasives
          1. Module Stdlib.Printexc
          1. Module Stdlib.Printf
          1. Module Stdlib.Queue
          1. Module Stdlib.Random
          1. Module Stdlib.Result
          1. Module Stdlib.Scanf
          1. Module Stdlib.Seq
          1. Module Stdlib.Set
          1. Module Stdlib.Stack
          1. Module Stdlib.StdLabels
          1. Module Stdlib.Stream
          1. Module Stdlib.String
          1. Module Stdlib.StringLabels
          1. Module Stdlib.Sys
          1. Module Stdlib.Uchar
          1. Module Stdlib.Unit
          1. Module Stdlib.Weak
        1. Module Str
        1. Module Thread
        1. Module ThreadUnix
        1. Module Topdirs
        1. Module Unix
          1. Module Unix.LargeFile
        1. Module UnixLabels
          1. Module UnixLabels.LargeFile
          1. Module EndianBigstring
          1. Module EndianBytes
          1. Module EndianString
      1. Package
      1. Package result
        1. Module Result
      1. Package stdint
        1. Module Stdint
          1. Module Stdint.Int128
          1. Module Stdint.Int16
          1. Module Stdint.Int24
          1. Module Stdint.Int32
          1. Module Stdint.Int40
          1. Module Stdint.Int48
          1. Module Stdint.Int56
          1. Module Stdint.Int64
          1. Module Stdint.Int8
          1. Module Stdint.Uint128
          1. Module Stdint.Uint16
          1. Module Stdint.Uint24
          1. Module Stdint.Uint32
          1. Module Stdint.Uint40
          1. Module Stdint.Uint48
          1. Module Stdint.Uint56
          1. Module Stdint.Uint64
          1. Module Stdint.Uint8