package bimage-unix

  1. Overview
  2. Docs

Source file bimage_unix.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
module Magick = Magick
module Stb = Stb
module Data_unix = Data
module Image_unix = Image

module Thread = struct
  module Filter () = struct
    include Bimage.Filter.Make (struct
      type 'a io = 'a

      let threads = Hashtbl.create 16

      let bind x (f : unit -> unit io) =
        let x = f x in
        x

      let detach f x =
        let t = Thread.create f x in
        Hashtbl.replace threads (Thread.id t) t

      let wrap f = f ()

      let wait () =
        Hashtbl.iter
          (fun k v ->
            let () = Thread.join v in
            Hashtbl.remove threads k)
          threads
    end)
  end
end
OCaml

Innovation. Community. Security.