]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
Added a getter for number of conns and timers.
authorPrashanth Mundkur <prashanth.mundkur@citrix.com>
Thu, 4 Jun 2009 18:44:52 +0000 (11:44 -0700)
committerPrashanth Mundkur <prashanth.mundkur@citrix.com>
Tue, 23 Jun 2009 16:25:36 +0000 (09:25 -0700)
libs/stdext/eventloop.ml
libs/stdext/eventloop.mli

index 9c68fc818322358afa6d243e90683876bee062b8..33d98cd140317095ab3147b5a02512b3be32dd56 100644 (file)
@@ -87,6 +87,11 @@ module Timers = struct
                                                      ) t.by_handle es;
                        List.map (fun e -> e.value) es
                with Not_found -> []
+
+       let num_timers t =
+               let cnt = ref 0 in
+               Timers_by_handle.iter (fun _ _ -> incr cnt) t.by_handle;
+               !cnt
 end
 
 type timer_callbacks =
@@ -366,3 +371,10 @@ let dispatch t interval =
        );
 
        dispatch_timers t ctime
+
+let num_connections t =
+       let cnt = ref 0 in
+       ConnMap.iter (fun _ _ -> incr cnt) t.conns;
+       !cnt
+
+let num_timers t = Timers.num_timers t.timers
index 0bf92562972e14e6b08d443baf9e6e14d28bc72f..fbd238e4da382ec5b66121fee679034045efea9c 100644 (file)
@@ -36,6 +36,8 @@ type conn_callbacks =
 (* this is to allow collections indexed by connection handles. *)
 val handle_compare : handle -> handle -> int
 
+(* Connection Management *)
+
 (* by default, connections are disabled for the send_done callback, and enabled for all others. *)
 val register_conn : t -> Unix.file_descr -> ?enable_send_done:bool -> ?enable_recv:bool -> conn_callbacks -> handle
 val remove_conn : t -> handle -> unit
@@ -55,7 +57,8 @@ val has_pending_send : t -> handle -> bool
 
 val set_callbacks : t -> handle -> conn_callbacks -> unit
 
-(* timers *)
+
+(* Timers *)
 
 type timer
 
@@ -68,9 +71,18 @@ type timer_callbacks =
 val start_timer : t -> float (* in seconds *) -> timer_callbacks -> timer
 val cancel_timer : t -> timer -> unit
 
-(* event dispatch *)
+
+(* Event Dispatch *)
 
 (* dispatch t intvl will block at most for intvl seconds, and dispatch
    any retrieved events and expired timers.
 *)
 val dispatch : t -> float -> unit
+
+
+(* Event loop management *)
+
+val num_connections : t -> int
+val num_timers : t -> int
+
+