WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] CA-40030: Option to remove an event by name from the p

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] CA-40030: Option to remove an event by name from the periodic scheduler
From: Rob Hoes <rob.hoes@xxxxxxxxxx>
Date: Fri, 9 Apr 2010 14:15:21 +0100
Delivery-date: Fri, 09 Apr 2010 06:17:24 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
CA-40030: Option to remove an event by name from the periodic scheduler

Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>

diff -r b9d60623be93 ocaml/xapi/ipq.ml
--- a/ocaml/xapi/ipq.ml Fri Apr 09 12:46:19 2010 +0100
+++ b/ocaml/xapi/ipq.ml Fri Apr 09 14:08:56 2010 +0100
@@ -92,7 +92,15 @@
     | m -> if ev = h.data.(n).ev then n else iter (n-1)
   in
   iter (h.size-1)
-
+  
+let find_p h f =
+  let rec iter n =
+    match n with
+      -1 -> -1
+    | m -> if f h.data.(n).ev then n else iter (n-1)
+  in
+  iter (h.size-1)
+  
 let pop_maximum h = let m = maximum h in remove h 0; m
   
 let iter f h = 
diff -r b9d60623be93 ocaml/xapi/xapi_periodic_scheduler.ml
--- a/ocaml/xapi/xapi_periodic_scheduler.ml     Fri Apr 09 12:46:19 2010 +0100
+++ b/ocaml/xapi/xapi_periodic_scheduler.ml     Fri Apr 09 14:08:56 2010 +0100
@@ -36,6 +36,12 @@
     Ipq.add queue { Ipq.ev={ func=newfunc; ty=ty; name=name}; 
Ipq.time=((Unix.gettimeofday ()) +. start) });
   if signal then Delay.signal delay
 
+let remove_from_queue name =
+       debug "Removing function %s from queue" name;
+       let index = Ipq.find_p queue (fun {name=n} -> name = n) in
+       if index > -1 then
+               Ipq.remove queue index
+  
 let loop () =
     debug "Periodic scheduler started";
     while true do
diff -r b9d60623be93 ocaml/xapi/xapi_periodic_scheduler.mli
--- a/ocaml/xapi/xapi_periodic_scheduler.mli    Fri Apr 09 12:46:19 2010 +0100
+++ b/ocaml/xapi/xapi_periodic_scheduler.mli    Fri Apr 09 14:08:56 2010 +0100
@@ -22,6 +22,9 @@
 val add_to_queue :
   ?signal:bool -> string -> func_ty -> float -> (unit -> unit) -> unit
 
+(** Remove a scheduled item by name *)
+val remove_from_queue : string -> unit
+
 (** The scheduler's main loop, started by {!Xapi} on start-up. *)
 val loop : unit -> unit
 

Attachment: remove-from-scheduler
Description: Text document

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] CA-40030: Option to remove an event by name from the periodic scheduler, Rob Hoes <=