jon.recoil.org

Module Domain.SafeSource

Submodule containing non-backwards-compatible functions which enforce thread safety via modes.

Sourcemodule DLS : sig ... end

Like DLS, but uses modes to enforce properties necessary for data-race freedom.

Sourcemodule TLS : sig ... end

Like TLS, but uses modes to enforce properties necessary for data-race freedom.

Sourceval spawn : (unit -> 'a) @ once portable -> 'a Stdlib.Domain.t @@ portable

Like spawn, but enforces thread-safety via modes. In particular, the provided computation must be portable, and so cannot close over and interact with any unsynchronized mutable data in the current domain.

  • alert do_not_spawn_domains User programs should never spawn domains. To execute a function on a domain, use [Multicore] from the threading library. This is because spawning more than [recommended_domain_count] domains (the CPU core count) will significantly degrade GC performance.
Sourceval at_exit : (unit -> unit) @ portable -> unit @@ portable

Like at_exit, but can be called from any domain.

The provided closure must be portable to enforce that it does not unsafely close over any data in the current capsule, which the current domain may not have uncontended access to at exit.