Skip to content

Commit

Permalink
lwt,eio: remove Client.socket
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Apr 19, 2024
1 parent 166e1e9 commit 8e4acb2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 47 deletions.
46 changes: 21 additions & 25 deletions eio/gluten_eio.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,14 @@ module IO_loop = struct

(* TODO(anmonteiro): since we stopped failing switches, [sw] is no longer
necessary. Consider removing the argument again. *)
let start :
type t.
(module Gluten.RUNTIME with type t = t)
-> read_buffer_size:int
-> read_closed:unit Promise.t * unit Promise.u
-> sw:Eio.Switch.t
-> t
-> _ Eio.Flow.two_way
-> unit
let start : type t.
(module Gluten.RUNTIME with type t = t)
-> read_buffer_size:int
-> read_closed:unit Promise.t * unit Promise.u
-> sw:Eio.Switch.t
-> t
-> _ Eio.Flow.two_way
-> unit
=
fun (module Runtime) ~read_buffer_size ~read_closed ~sw:_ t socket ->
let read_closed, resolve_read_closed = read_closed
Expand Down Expand Up @@ -176,12 +175,12 @@ module Server = struct
type addr = Eio.Net.Sockaddr.stream

let create_connection_handler
~read_buffer_size
~protocol
~sw
connection
_client_addr
socket
~read_buffer_size
~protocol
~sw
connection
_client_addr
socket
=
let connection = Gluten.Server.create ~protocol connection in
IO_loop.start
Expand All @@ -193,13 +192,13 @@ module Server = struct
socket

let create_upgradable_connection_handler
~read_buffer_size
~protocol
~create_protocol
~sw
~request_handler
(client_addr : addr)
socket
~read_buffer_size
~protocol
~create_protocol
~sw
~request_handler
(client_addr : addr)
socket
=
let connection =
Gluten.Server.create_upgradable
Expand All @@ -219,7 +218,6 @@ end
module Client = struct
type t =
{ connection : Gluten.Client.t
; socket : Eio_unix.Net.stream_socket_ty Eio.Net.stream_socket
; shutdown_reader : unit -> unit
; shutdown_complete : unit Promise.t
}
Expand All @@ -240,7 +238,6 @@ module Client = struct
connection
socket))));
{ connection
; socket
; shutdown_reader =
(fun () ->
let cancel_reader, resolve_cancel_reader = read_closed in
Expand All @@ -257,5 +254,4 @@ module Client = struct
t.shutdown_complete

let is_closed t = Gluten.Client.is_closed t.connection
let socket t = t.socket
end
1 change: 0 additions & 1 deletion eio/gluten_eio.mli
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ module Client : sig
val upgrade : t -> Gluten.impl -> unit
val shutdown : t -> unit Eio.Promise.t
val is_closed : t -> bool
val socket : t -> Eio_unix.Net.stream_socket_ty Eio.Net.stream_socket
end
38 changes: 18 additions & 20 deletions lwt/gluten_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ module IO_loop = struct
(fun n -> Lwt.wakeup_later u n);
p

let start :
type t fd.
(module IO with type socket = fd)
-> (module Gluten.RUNTIME with type t = t)
-> t
-> read_buffer_size:int
-> fd
-> unit Lwt.t
let start : type t fd.
(module IO with type socket = fd)
-> (module Gluten.RUNTIME with type t = t)
-> t
-> read_buffer_size:int
-> fd
-> unit Lwt.t
=
fun (module Io) (module Runtime) t ~read_buffer_size socket ->
let read_buffer = Buffer.create read_buffer_size in
Expand Down Expand Up @@ -122,11 +121,11 @@ module Server (Io : IO) = struct
type addr = Io.addr

let create_connection_handler
~read_buffer_size
~protocol
connection
_client_addr
socket
~read_buffer_size
~protocol
connection
_client_addr
socket
=
let connection = Server.create ~protocol connection in
IO_loop.start
Expand All @@ -137,12 +136,12 @@ module Server (Io : IO) = struct
socket

let create_upgradable_connection_handler
~read_buffer_size
~protocol
~create_protocol
~request_handler
client_addr
socket
~read_buffer_size
~protocol
~create_protocol
~request_handler
client_addr
socket
=
let connection =
Server.create_upgradable
Expand Down Expand Up @@ -187,5 +186,4 @@ module Client (Io : IO) = struct
Io.close t.socket

let is_closed t = Client_connection.is_closed t.connection
let socket t = t.socket
end
1 change: 0 additions & 1 deletion lwt/gluten_lwt_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,4 @@ module type Client = sig
val upgrade : t -> Gluten.impl -> unit
val shutdown : t -> unit Lwt.t
val is_closed : t -> bool
val socket : t -> socket
end

0 comments on commit 8e4acb2

Please sign in to comment.