Development kit - general purpose library
val init : unit -> unit

Enables thread marking. Use before calling other functions of this module.

val is_enabled : unit -> bool
val name : string -> ( unit -> 'a Lwt.t ) -> 'a Lwt.t

name n cont creates new lwt thread cont () marked with name n. Usage:

let myfunc () = "myfunc" @@ fun () -> <the_body>

val status : string Lazy.t -> ?dump:( 'a -> string ) -> ( unit -> 'a Lwt.t ) -> 'a Lwt.t

status lazy_name ?dump cont


lwt was_read = Lwt_mark.status (lazy (sprintf "reading %i bytes" to_read)) ~dump:string_of_int @@ fun () -> fd buf ofs to_read in

Start/exit of thread cont () will be logged to parent thread's last logs.

lazy_name must be able to be evaluated into a meaningful thread name when it is forced, no matter when (before thread startup, during thread execution, after thread exit).

Use ?dump argument when you need to log return value of the thread.

Internally status works like name, but statuses are groupped and displayed by summary in the section of thread that created them.

val status_s : string -> ?dump:( 'a -> string ) -> ( unit -> 'a Lwt.t ) -> 'a Lwt.t
val async : ?log:Log.logger -> string -> ( unit -> unit Lwt.t ) -> unit

async ?log name run_thread works like name + Lwt.async run_thread, but thread is marked as "background" (just for display purposes). Pass ~log to log thread failure with devkit logger (level = warn).

val ignore_result : ?log:Log.logger -> string -> ( unit -> unit Lwt.t ) -> unit

ignore_result == async. Deprecated. Note: this function takes argument run_thread that creates thread, not the thread itself, this differs from Lwt.ignore_result. Reason: functions of this module may be used during evaluation of (run_thread ()) : 'a Lwt.t, so we need to prepare Lwt thread storage before the evaluation of (run_thread ()).

val log : string -> unit

Adds line to current thread's last logs. When marking is enabled, but current thread is not marked/named, line is added to special "<top>" thread logs.

val log_l : string Lazy.t -> unit
val log_f : ( 'a, unit, string, unit ) format4 -> 'a
val summary : unit -> string

Human-readable marks summary: current running threads, their last logs and statuses.