package picos

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file run.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
open Picos

let wrap_all t main =
  Bundle.unsafe_incr t;
  fun () ->
    if Bundle.is_running t then begin
      try main () with exn -> Bundle.error t (Exn_bt.get exn)
    end;
    Bundle.decr t

let wrap_any t main =
  Bundle.unsafe_incr t;
  fun () ->
    if Bundle.is_running t then begin
      try
        main ();
        Bundle.terminate t
      with exn -> Bundle.error t (Exn_bt.get exn)
    end;
    Bundle.decr t

let run actions wrap =
  Bundle.join_after @@ fun t ->
  try
    let mains = List.map (wrap t) actions in
    Fiber.spawn ~forbid:false t.bundle mains
  with exn ->
    Bundle.unsafe_reset t;
    raise exn

let all actions = run actions wrap_all
let any actions = run actions wrap_any
OCaml

Innovation. Community. Security.