package riot

  1. Overview
  2. Docs
An actor-model multi-core scheduler for OCaml 5

Install

Dune Dependency

Authors

Maintainers

Sources

riot-0.0.5.tbz
sha256=01b7b82ccc656b12b7315960d9df17eb4682b8f1af68e9fee33171fee1f9cf88
sha512=d8831d8a75fe43a7e8d16d2c0bb7d27f6d975133e17c5dd89ef7e575039c59d27c1ab74fbadcca81ddfbc0c74d1e46c35baba35ef825b36ac6c4e49d7a41d0c2

doc/src/riot.core/proc_set.ml.html

Source file proc_set.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module PidSet = Set.Make (struct
  type t = Process.t

  let compare (a : t) (b : t) = Pid.compare (Process.pid a) (Process.pid b)
end)

type t = { _set : PidSet.t Atomic.t } [@@unboxed]

let create () = { _set = Atomic.make PidSet.empty }

let rec remove t proc =
  let old_set = Atomic.get t._set in
  let new_set = PidSet.remove proc old_set in
  if Atomic.compare_and_set t._set old_set new_set then () else remove t proc

let contains t proc = PidSet.mem proc (Atomic.get t._set)
let size t = PidSet.cardinal (Atomic.get t._set)

(* NOTE(leostera): `PidSet.add` actually keeps duplicates! we want to use `replace` to drop the old one *)
let rec add t proc =
  let old_set = Atomic.get t._set in
  let new_set = PidSet.add proc old_set in
  if Atomic.compare_and_set t._set old_set new_set then () else add t proc
OCaml

Innovation. Community. Security.