package matrix
Module Matrix_cli_unix.TaskSource
Tasks.
The type for tasks, the root among them.
The type for where a task is: running or how it ended.
start ~transient ~lines parent label is a task named label, started under parent, transient iff transient (false by default), whose window shows its latest lines lines of output (8 by default). A task started under one that ended is cancelled at once and prints nothing.
Raises Invalid_argument if lines is negative.
run ~transient ~lines parent label f is f t for the task t that start starts. t succeeds when f returns and fails when f raises, with the exception as its message, which is raised again. An ending f gave t counts.
items t ~total n says that t has done n items, out of total when given. Its rate is the count a second, weighing the past by exp (-. dt /. 2.) for dt seconds ago, and a count below the last starts it again.
Raises Invalid_argument if n or total is negative.
succeed ~message t ends t as a success, message after its label. The tasks under t that still run end first, and succeed with it.
fail ~message t ends t as a failure, message after its label. The tasks under t that still run are cancelled first.
cancel ~message t ends t as cancelled, message after its label. The tasks under t that still run are cancelled first.
type state = {label : string;status : status;message : string option;(*The message it ended with.
*)count : int;(*
*)0until it is counted.total : int option;unit : [ `Items | `Bytes ];(*What it counts.
*)elapsed : float;(*Seconds since it started, up to its end.
*)rate : float option;(*Its count a second, once it has one.
*)output : string list;(*Its lines of output, oldest first.
*)children : t list;(*The tasks started under it, oldest first.
*)
}The type for what a task is, at a time.
rows t ~width ~height is the rows of the running tasks under t, and the summary under them if t is the root, width cells wide, as `Tty draws them, for a frame of tasks to show with other grids. A task's row is its mark, its label, a bar when it has a total, its message, its count, its rate when it counts bytes, and its time, each in a column as wide as its widest cell. Rows taller than height give way: first the tasks that ended under each running task fold into one line, such as 10 done, 2 failed, then the windows shrink.