package eio
Effect-based direct-style IO API for OCaml
Install
Dune Dependency
Authors
Maintainers
Sources
eio-0.7.tbz
sha256=675e67f343ccf37b965d15d1ee1c639d7a06431e8f08e95559133419f3488ee1
sha512=3d1bd0e5e0aa79d8858d83944d734a0efc325ed66a12a1506c3b36281db56c0216e6cb90a46e6021db1ea34cdd2567ebabe0bd687d9989495bb7cf6099e90ba7
doc/src/eio.unix/eio_unix.ml.html
Source file eio_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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
type Eio.Exn.Backend.t += Unix_error of Unix.error * string * string let () = Eio.Exn.Backend.register_pp (fun f -> function | Unix_error (code, name, arg) -> Fmt.pf f "Unix_error (%s, %S, %S)" (Unix.error_message code) name arg; true | _ -> false ) type unix_fd = < unix_fd : [`Peek | `Take] -> Unix.file_descr; > type socket = < Eio.Flow.two_way; Eio.Flow.close; unix_fd; > module Private = struct type _ Eio.Generic.ty += Unix_file_descr : [`Peek | `Take] -> Unix.file_descr Eio.Generic.ty type _ Effect.t += | Await_readable : Unix.file_descr -> unit Effect.t | Await_writable : Unix.file_descr -> unit Effect.t | Get_monotonic_clock : Eio.Time.Mono.t Effect.t | Socket_of_fd : Eio.Switch.t * bool * Unix.file_descr -> socket Effect.t | Socketpair : Eio.Switch.t * Unix.socket_domain * Unix.socket_type * int -> (socket * socket) Effect.t | Pipe : Eio.Switch.t -> (<Eio.Flow.source; Eio.Flow.close; unix_fd> * <Eio.Flow.sink; Eio.Flow.close; unix_fd>) Effect.t end let await_readable fd = Effect.perform (Private.Await_readable fd) let await_writable fd = Effect.perform (Private.Await_writable fd) let sleep d = Eio.Time.Mono.sleep (Effect.perform Private.Get_monotonic_clock) d let run_in_systhread fn = let f fiber enqueue = match Eio.Private.Fiber_context.get_error fiber with | Some err -> enqueue (Error err) | None -> let _t : Thread.t = Thread.create (fun () -> enqueue (try Ok (fn ()) with exn -> Error exn)) () in () in Effect.perform (Eio.Private.Effects.Suspend f) module FD = struct let peek x = x#unix_fd `Peek let take x = x#unix_fd `Take let peek_opt x = Eio.Generic.probe x (Private.Unix_file_descr `Peek) let take_opt x = Eio.Generic.probe x (Private.Unix_file_descr `Take) let as_socket ~sw ~close_unix fd = Effect.perform (Private.Socket_of_fd (sw, close_unix, fd)) end let socketpair ~sw ?(domain=Unix.PF_UNIX) ?(ty=Unix.SOCK_STREAM) ?(protocol=0) () = Effect.perform (Private.Socketpair (sw, domain, ty, protocol)) let pipe sw = Effect.perform (Private.Pipe sw) module Ipaddr = struct let to_unix : _ Eio.Net.Ipaddr.t -> Unix.inet_addr = Obj.magic let of_unix : Unix.inet_addr -> _ Eio.Net.Ipaddr.t = Obj.magic end module Ctf = Ctf_unix let getnameinfo (sockaddr : Eio.Net.Sockaddr.t) = let sockaddr, options = match sockaddr with | `Unix s -> (Unix.ADDR_UNIX s, []) | `Tcp (addr, port) -> (Unix.ADDR_INET (Ipaddr.to_unix addr, port), []) | `Udp (addr, port) -> (Unix.ADDR_INET (Ipaddr.to_unix addr, port), [Unix.NI_DGRAM]) in run_in_systhread (fun () -> let Unix.{ni_hostname; ni_service} = Unix.getnameinfo sockaddr options in (ni_hostname, ni_service))
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>