Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated features #552

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib_eio/core/eio__core.mli
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,6 @@ module Fiber : sig
[fn] runs immediately, without switching to any other fiber first.
The calling fiber is placed at the head of the run queue, ahead of any previous items. *)

val fork_sub : sw:Switch.t -> on_error:(exn -> unit) -> (Switch.t -> unit) -> unit
[@@deprecated "Use Fiber.fork and Switch.run separately instead"]

val fork_promise : sw:Switch.t -> (unit -> 'a) -> 'a Promise.or_exn
(** [fork_promise ~sw fn] schedules [fn ()] to run in a new fiber and returns a promise for its result.

Expand Down
16 changes: 0 additions & 16 deletions lib_eio/core/fiber.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,6 @@ let pair f g =
let y = g () in
(Promise.await_exn x, y)

let fork_sub ~sw ~on_error f =
fork ~sw (fun () ->
try Switch.run f
with
| ex when Cancel.is_on sw.cancel ->
(* Typically the caller's context is within [sw], but it doesn't have to be.
It's possible that the original context has finished by now,
but [fork] is keeping [sw] alive so we can use that report the error. *)
Switch.run_in sw @@ fun () ->
try on_error ex
with ex2 ->
(* The [run_in] ensures [adopting_sw] isn't finished here *)
Switch.fail sw ex;
Switch.fail sw ex2
)

exception Not_first

let await_cancel () =
Expand Down
25 changes: 0 additions & 25 deletions lib_eio/unix/eio_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,10 @@ let sleep d =

let run_in_systhread = Private.run_in_systhread

(* Deprecated *)
module FD = struct
let peek t = Fd.use_exn "peek" (Resource.fd t) Fun.id

let peek_opt t =
match Resource.fd_opt t with
| None -> None
| Some fd -> Some (Fd.use_exn "peek_opt" fd Fun.id)

let take t = Fd.remove (Resource.fd t) |> Option.get

let take_opt t =
match Resource.fd_opt t with
| None -> None
| Some fd -> Fd.remove fd

let as_socket = Net.import_socket_stream
end

module Ipaddr = Net.Ipaddr

let socketpair ~sw ?domain ?(ty=Unix.SOCK_STREAM) ?protocol () =
assert (ty = Unix.SOCK_STREAM);
Net.socketpair_stream ~sw ?domain ?protocol ()

module Ctf = Ctf_unix

let getnameinfo = Net.getnameinfo

module Process = Process
module Net = Net

Expand Down
34 changes: 0 additions & 34 deletions lib_eio/unix/eio_unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,6 @@ val await_readable : Unix.file_descr -> unit
val await_writable : Unix.file_descr -> unit
(** [await_writable fd] blocks until [fd] is writable (or has an error). *)

(**/**)
module FD : sig
val peek : < Resource.t; .. > -> Unix.file_descr
[@@deprecated "Use Eio_unix.Resource.fd instead"]

val peek_opt : #Eio.Generic.t -> Unix.file_descr option
[@@deprecated "Use Eio_unix.Resource.fd_opt instead"]

val take : < Resource.t; .. > -> Unix.file_descr
[@@deprecated "Use Eio_unix.Resource.fd and Fd.remove instead"]

val take_opt : #Eio.Generic.t -> Unix.file_descr option
[@@deprecated "Use Eio_unix.Resource.fd_opt and Fd.remove instead"]

val as_socket : sw:Switch.t -> close_unix:bool -> Unix.file_descr -> Net.stream_socket
[@@deprecated "Use Eio_unix.Net.import_socket_stream instead"]
end

module Ipaddr = Net.Ipaddr
[@@deprecated "Use Eio_unix.Net.Ipaddr instead"]

val getnameinfo : Eio.Net.Sockaddr.t -> (string * string)
[@@deprecated "Use stdenv"]

val socketpair :
sw:Switch.t ->
?domain:Unix.socket_domain ->
?ty:Unix.socket_type ->
?protocol:int ->
unit ->
Net.stream_socket * Net.stream_socket
[@@@deprecated "Use Net.socketpair_stream"]
(**/**)

val sleep : float -> unit
(** [sleep d] sleeps for [d] seconds, allowing other fibers to run.
This is can be useful for debugging (e.g. to introduce delays to trigger a race condition)
Expand Down
34 changes: 15 additions & 19 deletions lib_eio_linux/eio_linux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@ open Eio.Std

module Fiber_context = Eio.Private.Fiber_context
module Ctf = Eio.Private.Ctf
module Fd = Eio_unix.Fd

module Suspended = Eio_utils.Suspended
module Zzz = Eio_utils.Zzz
module Lf_queue = Eio_utils.Lf_queue

module Low_level = Low_level

(* Deprecated FD code *)
module FD = Fd
let get_fd = Eio_unix.Resource.fd
let get_fd_opt = Eio_unix.Resource.fd_opt

type _ Eio.Generic.ty += Dir_fd : Low_level.dir_fd Eio.Generic.ty
let get_dir_fd_opt t = Eio.Generic.probe t Dir_fd

Expand Down Expand Up @@ -112,7 +108,7 @@ let datagram_socket sock = object

method fd = sock

method close = FD.close sock
method close = Fd.close sock

method send ?dst buf =
let dst = Option.map Eio_unix.Net.sockaddr_to_unix dst in
Expand All @@ -125,10 +121,10 @@ let datagram_socket sock = object
end

let flow fd =
let is_tty = FD.use_exn "isatty" fd Unix.isatty in
let is_tty = Fd.use_exn "isatty" fd Unix.isatty in
object (_ : <source; sink; ..>)
method fd = fd
method close = FD.close fd
method close = Fd.close fd

method stat = Low_level.fstat fd

Expand Down Expand Up @@ -178,7 +174,7 @@ let sink fd = (flow fd :> sink)
let listening_socket fd = object
inherit Eio.Net.listening_socket

method close = FD.close fd
method close = Fd.close fd

method accept ~sw =
Switch.check sw;
Expand Down Expand Up @@ -208,7 +204,7 @@ let socket_domain_of = function
let connect ~sw connect_addr =
let addr = Eio_unix.Net.sockaddr_to_unix connect_addr in
let sock_unix = Unix.socket ~cloexec:true (socket_domain_of connect_addr) Unix.SOCK_STREAM 0 in
let sock = FD.of_unix ~sw ~seekable:false ~close_unix:true sock_unix in
let sock = Fd.of_unix ~sw ~seekable:false ~close_unix:true sock_unix in
Low_level.connect sock addr;
(flow sock :> Eio.Net.stream_socket)

Expand All @@ -228,7 +224,7 @@ let net = object
);
let addr = Eio_unix.Net.sockaddr_to_unix listen_addr in
let sock_unix = Unix.socket ~cloexec:true (socket_domain_of listen_addr) Unix.SOCK_STREAM 0 in
let sock = FD.of_unix ~sw ~seekable:false ~close_unix:true sock_unix in
let sock = Fd.of_unix ~sw ~seekable:false ~close_unix:true sock_unix in
(* For Unix domain sockets, remove the path when done (except for abstract sockets). *)
begin match listen_addr with
| `Unix path ->
Expand Down Expand Up @@ -258,7 +254,7 @@ let net = object
| exception Unix.Unix_error (code, name, arg) -> raise @@ Err.wrap code name arg
);
let sock_unix = Unix.socket ~cloexec:true (socket_domain_of saddr) Unix.SOCK_DGRAM 0 in
let sock = FD.of_unix ~sw ~seekable:false ~close_unix:true sock_unix in
let sock = Fd.of_unix ~sw ~seekable:false ~close_unix:true sock_unix in
begin match saddr with
| `Udp _ | `Unix _ as saddr ->
let addr = Eio_unix.Net.sockaddr_to_unix saddr in
Expand Down Expand Up @@ -418,7 +414,7 @@ class dir ~label (fd : Low_level.dir_fd) = object

method close =
match fd with
| FD x -> FD.close x
| FD x -> Fd.close x
| Cwd | Fs -> failwith "Can't close non-FD directory!"

method unlink path = Low_level.unlink ~rmdir:false fd path
Expand Down Expand Up @@ -466,18 +462,18 @@ let run_event_loop (type a) ?fallback config (main : _ -> a) arg : a =
match e with
| Eio_unix.Private.Get_monotonic_clock -> Some (fun k -> continue k mono_clock)
| Eio_unix.Net.Import_socket_stream (sw, close_unix, fd) -> Some (fun k ->
let fd = FD.of_unix ~sw ~seekable:false ~close_unix fd in
let fd = Fd.of_unix ~sw ~seekable:false ~close_unix fd in
continue k (flow fd :> Eio_unix.Net.stream_socket)
)
| Eio_unix.Net.Import_socket_datagram (sw, close_unix, fd) -> Some (fun k ->
let fd = FD.of_unix ~sw ~seekable:false ~close_unix fd in
let fd = Fd.of_unix ~sw ~seekable:false ~close_unix fd in
continue k (datagram_socket fd)
)
| Eio_unix.Net.Socketpair_stream (sw, domain, protocol) -> Some (fun k ->
match
let a, b = Unix.socketpair ~cloexec:true domain Unix.SOCK_STREAM protocol in
let a = FD.of_unix ~sw ~seekable:false ~close_unix:true a |> flow in
let b = FD.of_unix ~sw ~seekable:false ~close_unix:true b |> flow in
let a = Fd.of_unix ~sw ~seekable:false ~close_unix:true a |> flow in
let b = Fd.of_unix ~sw ~seekable:false ~close_unix:true b |> flow in
((a :> Eio_unix.Net.stream_socket), (b :> Eio_unix.Net.stream_socket))
with
| r -> continue k r
Expand All @@ -487,8 +483,8 @@ let run_event_loop (type a) ?fallback config (main : _ -> a) arg : a =
| Eio_unix.Net.Socketpair_datagram (sw, domain, protocol) -> Some (fun k ->
match
let a, b = Unix.socketpair ~cloexec:true domain Unix.SOCK_DGRAM protocol in
let a = FD.of_unix ~sw ~seekable:false ~close_unix:true a |> datagram_socket in
let b = FD.of_unix ~sw ~seekable:false ~close_unix:true b |> datagram_socket in
let a = Fd.of_unix ~sw ~seekable:false ~close_unix:true a |> datagram_socket in
let b = Fd.of_unix ~sw ~seekable:false ~close_unix:true b |> datagram_socket in
((a :> Eio_unix.Net.datagram_socket), (b :> Eio_unix.Net.datagram_socket))
with
| r -> continue k r
Expand Down
20 changes: 0 additions & 20 deletions lib_eio_linux/eio_linux.mli
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,13 @@ open Eio.Std

type fd := Eio_unix.Fd.t

(**/**)
module FD : sig
type t = fd

val is_open : t -> bool
val close : t -> unit
val of_unix : sw:Switch.t -> seekable:bool -> close_unix:bool -> Unix.file_descr -> t
val to_unix : [< `Peek | `Take] -> t -> Unix.file_descr
end
[@@deprecated "Use Eio_unix.Fd instead"]
(**/**)

(** {1 Eio API} *)

type source = Eio_unix.source
type sink = Eio_unix.sink

type stdenv = Eio_unix.Stdenv.base

(**/**)
val get_fd : <Eio_unix.Resource.t; ..> -> fd
[@@deprecated "Use Eio_unix.Resource.fd instead"]

val get_fd_opt : #Eio.Generic.t -> fd option
[@@deprecated "Use Eio_unix.Resource.fd_opt instead"]
(**/**)

(** {1 Main Loop} *)

val run :
Expand Down
14 changes: 0 additions & 14 deletions lib_eio_linux/fd.ml

This file was deleted.

14 changes: 0 additions & 14 deletions lib_eio_posix/fd.ml

This file was deleted.

47 changes: 0 additions & 47 deletions lib_eio_posix/fd.mli

This file was deleted.

2 changes: 1 addition & 1 deletion lib_eio_posix/low_level.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open Eio.Std

type ty = Read | Write

module Fd = Fd
module Fd = Eio_unix.Fd

(* todo: keeping a pool of workers is probably faster *)
let in_worker_thread = Eio_unix.run_in_systhread
Expand Down
3 changes: 0 additions & 3 deletions lib_eio_posix/low_level.mli
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ open Eio.Std

type fd := Eio_unix.Fd.t

module Fd = Fd
[@@deprecated "Use Eio_unix.Fd instead"]

val await_readable : fd -> unit
val await_writable : fd -> unit

Expand Down
2 changes: 1 addition & 1 deletion lib_eio_windows/test/test_net.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ let test_wrap_socket pipe_or_socketpair () =

let test_eio_socketpair () =
Switch.run @@ fun sw ->
let a, b = Eio_unix.socketpair ~sw () in
let a, b = Eio_unix.Net.socketpair_stream ~sw () in
ignore (Eio_unix.Resource.fd a : Eio_unix.Fd.t);
ignore (Eio_unix.Resource.fd b : Eio_unix.Fd.t);
Eio.Flow.copy_string "foo" a;
Expand Down