-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconn_map.ml
43 lines (34 loc) · 1.19 KB
/
conn_map.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
(*
* Copyright (C) 2009 Citrix Ltd.
* Author Prashanth Mundkur <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License (version
* 2.1 only) as published by the Free Software Foundation, with the
* special exception on linking described in file LICENSE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)
module type CONN_INFO =
sig
type conn
end
module Make (ConnInfo : CONN_INFO) =
struct
module ConnMap = Map.Make (struct type t = Eventloop.handle
let compare = Eventloop.handle_compare
end)
let conns = ref (ConnMap.empty : ConnInfo.conn ConnMap.t)
(* Connection handling utilities *)
let add_conn h conn =
conns := ConnMap.add h conn !conns
let get_conn h =
ConnMap.find h !conns
let has_conn h =
ConnMap.mem h !conns
let remove_conn h =
conns := ConnMap.remove h !conns
end