diff --git a/index.html b/index.html index 4823706..b647975 100644 --- a/index.html +++ b/index.html @@ -1,2 +1,2 @@ -_opam

OCaml package documentation

Browse by name, by tag, the standard library and the OCaml manual (online, latest version).

Generated for /home/runner/work/ocaml-trace/ocaml-trace/_opam/lib

Packages by name

m

  1. mtime

o

  1. ocaml
  2. ocaml-compiler-libs

p

  1. ppx_trace
  2. ppxlib

s

  1. sexplib0

t

  1. trace
  2. trace-fuchsia
  3. trace-tef

Packages by tag

\ No newline at end of file +_opam

OCaml package documentation

Browse by name, by tag, the standard library and the OCaml manual (online, latest version).

Generated for /home/runner/work/ocaml-trace/ocaml-trace/_opam/lib

Packages by name

m

  1. mtime

o

  1. ocaml
  2. ocaml-compiler-libs

p

  1. ppx_trace
  2. ppxlib

s

  1. sexplib0

t

  1. thread-local-storage
  2. trace
  3. trace-fuchsia
  4. trace-tef

Packages by tag

\ No newline at end of file diff --git a/thread-local-storage/Thread_local_storage/index.html b/thread-local-storage/Thread_local_storage/index.html new file mode 100644 index 0000000..558034e --- /dev/null +++ b/thread-local-storage/Thread_local_storage/index.html @@ -0,0 +1,2 @@ + +Thread_local_storage (thread-local-storage.Thread_local_storage)

Module Thread_local_storage

Thread local storage

type 'a t

A TLS slot for values of type 'a. This allows the storage of a single value of type 'a per thread.

val create : unit -> 'a t

Allocate a new TLS slot. The TLS slot starts uninitialised on each thread.

Note: each TLS slot allocated consumes a word per thread, and it can never be deallocated. create should be called at toplevel to produce constants, do not use it in a loop.

  • raises Failure

    if no more TLS slots can be allocated.

exception Not_set

Exception raised when accessing a slot that was not previously set on this thread

val get_exn : 'a t -> 'a

get_exn x returns the value previously stored in the TLS slot x for the current thread.

This function is safe to use from asynchronous callbacks without risks of races.

  • raises Not_set

    if the TLS slot has not been initialised in the current thread. Do note that this uses raise_notrace for performance reasons, so make sure to always catch the exception as it will not carry a backtrace.

val get_opt : 'a t -> 'a option

get_opt x returns Some v where v is the value previously stored in the TLS slot x for the current thread. It returns None if the TLS slot has not been initialised in the current thread.

This function is safe to use from asynchronous callbacks without risks of races.

val get_default : default:(unit -> 'a) -> 'a t -> 'a

get_default x ~default returns the value previously stored in the TLS slot x for the current thread. If the TLS slot has not been initialised, default () is called, and its result is returned instead, after being stored in the TLS slot x.

If the call to default () raises an exception, then the TLS slot remains uninitialised. If default is a function that always raises, then this function is safe to use from asynchronous callbacks without risks of races.

  • raises Out_of_memory
val set : 'a t -> 'a -> unit

set x v stores v into the TLS slot x for the current thread.

  • raises Out_of_memory
diff --git a/thread-local-storage/Thread_local_storage__/index.html b/thread-local-storage/Thread_local_storage__/index.html new file mode 100644 index 0000000..395b7b1 --- /dev/null +++ b/thread-local-storage/Thread_local_storage__/index.html @@ -0,0 +1,2 @@ + +Thread_local_storage__ (thread-local-storage.Thread_local_storage__)

Module Thread_local_storage__

This module is hidden.

diff --git a/thread-local-storage/Thread_local_storage__Atomic/index.html b/thread-local-storage/Thread_local_storage__Atomic/index.html new file mode 100644 index 0000000..48ff275 --- /dev/null +++ b/thread-local-storage/Thread_local_storage__Atomic/index.html @@ -0,0 +1,2 @@ + +Thread_local_storage__Atomic (thread-local-storage.Thread_local_storage__Atomic)

Module Thread_local_storage__Atomic

This module is hidden.

diff --git a/thread-local-storage/_doc-dir/CHANGES.md b/thread-local-storage/_doc-dir/CHANGES.md new file mode 100644 index 0000000..91e239a --- /dev/null +++ b/thread-local-storage/_doc-dir/CHANGES.md @@ -0,0 +1,11 @@ + +# 0.2 + +- Incompatible API change, making things simpler. +- It is now safe to read TLS from asynchronous callbacks (e.g. memprof + callbacks). + +# 0.1 + +initial release + diff --git a/thread-local-storage/_doc-dir/LICENSE b/thread-local-storage/_doc-dir/LICENSE new file mode 100644 index 0000000..11be746 --- /dev/null +++ b/thread-local-storage/_doc-dir/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Simon Cruanes + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/thread-local-storage/_doc-dir/README.md b/thread-local-storage/_doc-dir/README.md new file mode 100644 index 0000000..ff9ad24 --- /dev/null +++ b/thread-local-storage/_doc-dir/README.md @@ -0,0 +1,10 @@ +# Thread-local storage + +The classic threading utility: have variables that have a value for each thread. + +See https://discuss.ocaml.org/t/a-hack-to-implement-efficient-tls-thread-local-storage/13264 for the initial implementation +by @polytypic. + +## License + +MIT diff --git a/thread-local-storage/index.html b/thread-local-storage/index.html new file mode 100644 index 0000000..b5e621f --- /dev/null +++ b/thread-local-storage/index.html @@ -0,0 +1,2 @@ + +index (thread-local-storage.index)

Package thread-local-storage

Package info

changes-files
license-files
readme-files
diff --git a/trace/Trace_thread_local_storage/index.html b/trace/Trace_thread_local_storage/index.html new file mode 100644 index 0000000..c74bf68 --- /dev/null +++ b/trace/Trace_thread_local_storage/index.html @@ -0,0 +1,2 @@ + +Trace_thread_local_storage (trace.Trace_thread_local_storage)

Module Trace_thread_local_storage

use thread-local-storage to store ambient spans.

This doesn't work with cooperative concurrency (Eio, Lwt, etc) but is fine in a threaded context.

Key to access the current span

val setup : unit -> unit

Install the provider

diff --git a/trace/index.html b/trace/index.html index 4322095..d46d9a9 100644 --- a/trace/index.html +++ b/trace/index.html @@ -1,2 +1,2 @@ -index (trace.index)

Package trace

Package info

changes-files
readme-files
+index (trace.index)

Package trace

Package info

changes-files
readme-files