-
Notifications
You must be signed in to change notification settings - Fork 13
/
stdcompat__domain.ml.in
71 lines (57 loc) · 1.21 KB
/
stdcompat__domain.ml.in
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@BEGIN_FROM_5_0_0@
include Domain
@END_FROM_5_0_0@
@BEGIN_BEFORE_5_0_0@
@BEGIN_FROM_4_12_0@
type !'a t = 'a
@END_FROM_4_12_0@
@BEGIN_BEFORE_4_12_0@
type 'a t = 'a
@END_BEFORE_4_12_0@
type id = int
module DLS = struct
type 'a key = {
split_from_parent: ('a -> 'a) option;
f: unit -> 'a;
mutable value: 'a option;
}
let new_key ?split_from_parent f =
{ split_from_parent; f; value = None }
let get key =
match key.value with
| Some value -> value
| None ->
let value = key.f () in
key.value <- Some value;
value
let set key value =
key.value <- Some value
end
let before_first_spawn_list = ref (Some [])
let spawn f =
begin match !before_first_spawn_list with
| None -> ()
| Some list ->
List.iter (fun f -> f ()) (List.rev list);
before_first_spawn_list := None
end;
f ()
let join v =
v
let get_id _v =
0
let self () =
0
let before_first_spawn f =
match !before_first_spawn_list with
| None -> invalid_arg "Already spawned"
| Some list -> before_first_spawn_list := Some (f :: list)
let at_exit f =
at_exit f
let cpu_relax () =
()
let is_main_domain () =
true
let recommended_domain_count () =
1
@END_BEFORE_5_0_0@