state := Whenstate.set_variable !state name value;
(* Which jobs need to be re-evaluated? *)
- let jobs = Whenstate.get_dependencies !state name in
+ let jobs = Whenstate.get_dependencies !state [name] in
reevaluate_whenjobs jobs;
`ok
let nr_jobs t = List.length t.jobs
-let get_dependencies t name =
- let jobnames = try StringMap.find name t.dependencies with Not_found -> [] in
+let get_dependencies t names =
+ (* Get all job names that depend on these variables. *)
+ let jobnames =
+ List.map (
+ fun name ->
+ try StringMap.find name t.dependencies with Not_found -> []
+ ) names in
+
+ (* Flatten the list and remove duplicates. *)
+ let set = List.fold_left (
+ fun set jn -> StringSet.add jn set
+ ) StringSet.empty (List.flatten jobnames) in
+ let jobnames = StringSet.elements set in
+
+ (* Convert job names to jobs. *)
List.map (fun jn ->
try
let j = StringMap.find jn t.jobmap in
val nr_jobs : t -> int
(** Returns the number of jobs in the state. *)
-val get_dependencies : t -> string -> Whenexpr.job list
-(** Return the jobs which depend on the named variable. *)
+val get_dependencies : t -> string list -> Whenexpr.job list
+(** Return the jobs which depend on the named variables. *)
val get_whenjobs : t -> Whenexpr.job list
val get_everyjobs : t -> Whenexpr.job list