- let next = List.sort (fun (t1,_,_) (t2,_,_) -> compare t1 t2) next in
- let next_t, name, f = List.hd next in
-
- let name = match name with Some name -> name | None -> "[unnamed]" in
-
- (* Run it after waiting for the appropriate amount of time. *)
- let seconds = int_of_float (next_t -. now) in
- eprintf "next job '%s' will run in %s\n%!" name (printable_seconds seconds);
+ let jobs = List.sort (fun (t1,_) (t2,_) -> compare t1 t2) jobs in
+
+ (* Find all jobs that have the same next time.
+ * XXX When we can handle parallel jobs we can do better here,
+ * but until them run all the ones which have the same time
+ * in series.
+ *)
+ let next_t = int_of_float (fst (List.hd jobs)) in
+ let jobs = List.filter (fun (t, _) -> int_of_float t = next_t) jobs in
+
+ (* Run next job(s) after waiting for the appropriate amount of time. *)
+ let seconds = next_t - int_of_float now in
+ eprintf "next job will run in %s\n%!" (printable_seconds seconds);