]> git.ozlabs.org Git - ccan/blobdiff - ccan/timer/_info
timer: change timers_expire() to return a single timer.
[ccan] / ccan / timer / _info
index cb6808b436c2231671341c4f77acdb0e818a44e1..420aba1145ad46372d6a34172c5a837d32800a2b 100644 (file)
@@ -1,5 +1,6 @@
-#include <string.h>
 #include "config.h"
+#include <stdio.h>
+#include <string.h>
 
 /**
  * timer - efficient implementation of rarely-expiring timers.
@@ -27,7 +28,7 @@
  *     {
  *             struct timers timers;
  *             struct list_head strings;
- *             struct list_head expired;
+ *             struct timer *t;
  *             struct timed_string *s;
  *
  *             timers_init(&timers, time_now());
  *                     s = malloc(sizeof(*s));
  *                     s->string = argv[1];
  *                     timer_add(&timers, &s->timer,
- *                               time_add(time_now(),
- *                                        time_from_msec(atol(argv[2]))));
+ *                               timeabs_add(time_now(),
+ *                                           time_from_msec(atol(argv[2]))));
  *                     list_add_tail(&strings, &s->node);
  *                     argv += 2;
  *             }
  *
  *             while (!list_empty(&strings)) {
- *                     struct timespec now = time_now();
+ *                     struct timeabs now = time_now();
  *                     list_for_each(&strings, s, node)
  *                             printf("%s", s->string);
- *                     timers_expire(&timers, now, &expired);
- *                     while ((s = list_pop(&expired, struct timed_string,
- *                                          timer.list)) != NULL) {
+ *                     while ((t = timers_expire(&timers, now)) != NULL) {
+ *                             s = container_of(t, struct timed_string, timer);
  *                             list_del_from(&strings, &s->node);
  *                             free(s);
  *                     }