-
Notifications
You must be signed in to change notification settings - Fork 0
/
robust-emit-sig.sml
executable file
·31 lines (26 loc) · 1.25 KB
/
robust-emit-sig.sml
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
(* A version of EMIT_PROGRAM that uses Backup. *)
signature ROBUST_EMIT =
sig
datatype status =
(* Fraction of program that has been played, in [0, 1) *)
Progress of real
(* Can't continue, because the next cell in the
program (given) is dead, and there is no working backup. *)
(* TODO: If the cell is killed and zombied, then we probably
want to indicate that we're just toast. *)
| Paused of int
(* Finished emitting. The int is the slot number we used. *)
| Done of int
(* Pass in something reasonable for backup_stride. 20 to 50 percent
* of the input program's length is a solid bet. *)
type emit_args = { turns : LTG.turn list, use_addressable : bool,
backup_stride : int }
(* Create the dominator. Must be spawned by the caller.
The child dominator will ignore the slots that the turn list modifies;
instead, it will assume the turns all operate on the same slot, and
generate them in a custom slot. (An exception will be thrown if that
invariant is not held.) *)
val emit : DOS.dos -> emit_args -> status ref * DOS.dominator
(* Emit at the process's current priority, returning the pid. *)
val emitspawn : DOS.dos -> emit_args -> status ref * DOS.pid
end