add CCThread.spawn{1,2}

This commit is contained in:
Simon Cruanes 2016-01-25 17:16:58 +01:00
parent 32fad92be8
commit 40c38a5dab
2 changed files with 13 additions and 1 deletions

View file

@ -6,6 +6,10 @@ type t = Thread.t
let spawn f = Thread.create f ()
let spawn1 f x = Thread.create f x
let spawn2 f x y = Thread.create (fun () -> f x y) ()
let detach f = ignore (Thread.create f ())
module Arr = struct

View file

@ -7,9 +7,17 @@
type t = Thread.t
val spawn : (unit -> 'a) -> t
val spawn : (unit -> _) -> t
(** [spawn f] creates a new thread that runs [f ()] *)
val spawn1 : ('a -> _) -> 'a -> t
(** [spawn1 f x] is like [spawn (fun () -> f x)].
@since NEXT_RELEASE *)
val spawn2 : ('a -> 'b -> _) -> 'a -> 'b -> t
(** [spawn2 f x y] is like [spawn (fun () -> f x y)].
@since NEXT_RELEASE *)
val detach : (unit -> 'a) -> unit
(** [detach f] is the same as [ignore (spawn f)] *)