package picos

  1. Overview
  2. Docs
Pico scheduler interface

Install

Dune Dependency

Authors

Maintainers

Sources

picos-0.4.0.tbz
sha256=343a8b4759239ca0c107145b8e2cc94c14625fecc0b0887d3c40a9ab7537b8da
sha512=db22b0a5b3adc603c0e815c9011c779f892b9ace76be018b2198d3e24a7d96727c999701025fe5a5fd07d0b452cb7286fc50c939aba0e4dce809941e9ebc12a6

doc/src/picos.fd/picos_fd.ml.html

Source file picos_fd.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
33
34
let report_leaks = ref true

module File_descr = struct
  type t = Unix.file_descr

  let equal : t -> t -> bool = ( == )

  let hash (fd : t) =
    if Obj.is_int (Obj.repr fd) then Obj.magic fd else Hashtbl.hash fd

  let dispose = Unix.close
end

include Picos_rc.Make (File_descr) ()

let () =
  Stdlib.at_exit @@ fun () ->
  if !report_leaks then
    infos ()
    |> Seq.iter @@ fun info ->
       if 0 < info.count && info.dispose then begin
         if Obj.is_int (Obj.repr info.resource) then
           Printf.eprintf "Leaked file descriptor (%d).\n%!"
             (Obj.magic info.resource)
         else Printf.eprintf "Leaked file descriptor.\n%!";
         match Printexc.backtrace_slots info.bt with
         | None -> ()
         | Some slots ->
             slots
             |> Array.iteri @@ fun i slot ->
                if i <> 0 then
                  Printexc.Slot.format i slot
                  |> Option.iter (Printf.eprintf "  %s\n%!")
       end
OCaml

Innovation. Community. Security.