lwt_unix.mli (2292B)
1 (* Module [Lwt_unix]: thread-compatible system calls *) 2 3 val sleep : float -> unit Lwt.t 4 (* [sleep d] is a threads which remain suspended for [d] seconds 5 (letting other threads run) and then terminates. *) 6 val yield : unit -> unit Lwt.t 7 (* [yield ()] is a threads which suspends itself (letting other 8 thread run) and then resumes as soon as possible and 9 terminates. *) 10 11 val run : 'a Lwt.t -> 'a 12 (* [run t] lets the thread [t] run until it terminates. It 13 evaluates to the return value of [t], or raise the exception 14 associated to [t] if [t] fails. 15 16 You should avoid using [run] inside threads: 17 - The calling threads will not resume before [run] 18 returns. 19 - Successive invocations of [run] are serialized: an 20 invocation of [run] will not terminate before all 21 subsequent invocations are terminated. *) 22 23 (****) 24 25 (* These functions behaves as their [Unix] counterparts, but let other 26 threads run while waiting for the completion of the system call. 27 28 PITFALL 29 If you want to read or write from stdin, stdout or stderr using 30 this library, you must first turn them into non-blocking mode 31 using [Unix.set_nonblock]. *) 32 33 type file_descr 34 35 val of_unix_file_descr : Unix.file_descr -> file_descr 36 37 val read : file_descr -> bytes -> int -> int -> int Lwt.t 38 val write : file_descr -> bytes -> int -> int -> int Lwt.t 39 val write_substring : file_descr -> string -> int -> int -> int Lwt.t 40 val wait_read : file_descr -> unit Lwt.t 41 val wait_write : file_descr -> unit Lwt.t 42 val pipe_in : ?cloexec:bool -> unit -> file_descr * Unix.file_descr 43 val pipe_out : ?cloexec:bool -> unit -> Unix.file_descr * file_descr 44 val socket : 45 ?cloexec:bool -> Unix.socket_domain -> Unix.socket_type -> int -> file_descr 46 val bind : file_descr -> Unix.sockaddr -> unit 47 val setsockopt : file_descr -> Unix.socket_bool_option -> bool -> unit 48 val accept : file_descr -> (file_descr * Unix.sockaddr) Lwt.t 49 val connect : file_descr -> Unix.sockaddr -> unit Lwt.t 50 val listen : file_descr -> int -> unit 51 val close : file_descr -> unit 52 val set_close_on_exec : file_descr -> unit 53 54 type lwt_in_channel 55 56 val intern_in_channel : in_channel -> lwt_in_channel 57 val input_line : lwt_in_channel -> string Lwt.t