[go: up one dir, main page]

Skip to content

Commit

Permalink
Add: pool module
Browse files Browse the repository at this point in the history
  • Loading branch information
muqiuhan committed Sep 21, 2023
1 parent 33ed5fd commit 30bd742
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions kernel/lib/pool/connection_pool.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Connection_pool = Hashtbl.Make (String)

type t = Io.Client.t Connection_pool.t

let add pool (connection_id, connection_client) =
match Connection_pool.find_opt pool connection_id with
| Some _ -> Io.Client.close connection_client
| None -> Connection_pool.add pool connection_id connection_client

let get pool connection_id = Connection_pool.find connection_id pool
2 changes: 1 addition & 1 deletion kernel/lib/pool/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(library
(name pool)
(libraries core dream log))
(libraries core dream io log))

0 comments on commit 30bd742

Please sign in to comment.