nn_timeout renamed to nn_timerset

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 13c9eea..c048b9c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -116,8 +116,8 @@
     utils/stream.c
     utils/thread.h
     utils/thread.c
-    utils/timeout.h
-    utils/timeout.c
+    utils/timerset.h
+    utils/timerset.c
     utils/wire.h
     utils/wire.c
 
diff --git a/src/utils/aio.h b/src/utils/aio.h
index 6e42931..466e047 100644
--- a/src/utils/aio.h
+++ b/src/utils/aio.h
@@ -103,14 +103,14 @@
 #if defined NN_HAVE_WINDOWS
 
 #include "win.h"
-#include "timeout.h"
+#include "timerset.h"
 #include "thread.h"
 #include "mutex.h"
 
 struct nn_timer {
     const struct nn_cp_sink **sink;
     struct nn_cp *cp;
-    struct nn_timeout_hndl hndl;
+    struct nn_timerset_hndl hndl;
 };
 
 struct nn_event {
@@ -145,7 +145,7 @@
 
 struct nn_cp {
     struct nn_mutex sync;
-    struct nn_timeout timeout;
+    struct nn_timerset timeout;
     HANDLE hndl;
 
     /*  The values of these members are never used. They serve just like
@@ -161,7 +161,7 @@
 #include "efd.h"
 #include "poller.h"
 #include "queue.h"
-#include "timeout.h"
+#include "timerset.h"
 #include "thread.h"
 #include "mutex.h"
 
@@ -171,7 +171,7 @@
 struct nn_timer {
     const struct nn_cp_sink **sink;
     struct nn_cp *cp;
-    struct nn_timeout_hndl hndl;
+    struct nn_timerset_hndl hndl;
 };
 
 struct nn_event {
@@ -232,7 +232,7 @@
 
 struct nn_cp {
     struct nn_mutex sync;
-    struct nn_timeout timeout;
+    struct nn_timerset timeout;
     struct nn_efd efd;
     struct nn_poller_hndl efd_hndl;
     struct nn_poller poller;
diff --git a/src/utils/aio_posix.inc b/src/utils/aio_posix.inc
index b6c33f9..9b203d2 100644
--- a/src/utils/aio_posix.inc
+++ b/src/utils/aio_posix.inc
@@ -48,13 +48,13 @@
 {
     self->sink = sink;
     self->cp = cp;
-    nn_timeout_hndl_init (&self->hndl);
+    nn_timerset_hndl_init (&self->hndl);
 }
 
 void nn_timer_term (struct nn_timer *self)
 {
     nn_timer_stop (self);
-    nn_timeout_hndl_term (&self->hndl);
+    nn_timerset_hndl_term (&self->hndl);
 }
 
 void nn_timer_start (struct nn_timer *self, int timeout)
@@ -62,10 +62,10 @@
     int rc;
 
     /*  If the timer is active, cancel it first. */
-    if (nn_timeout_hndl_isactive (&self->hndl))
+    if (nn_timerset_hndl_isactive (&self->hndl))
         nn_timer_stop (self);
 
-    rc = nn_timeout_add (&self->cp->timeout, timeout, &self->hndl);
+    rc = nn_timerset_add (&self->cp->timeout, timeout, &self->hndl);
     errnum_assert (rc >= 0, -rc);
 
     if (rc == 1 && !nn_thread_current (&self->cp->worker))
@@ -77,10 +77,10 @@
     int rc;
 
     /*  If the timer is not active, do nothing. */
-    if (!nn_timeout_hndl_isactive (&self->hndl))
+    if (!nn_timerset_hndl_isactive (&self->hndl))
          return;
 
-    rc = nn_timeout_rm (&self->cp->timeout, &self->hndl);
+    rc = nn_timerset_rm (&self->cp->timeout, &self->hndl);
     errnum_assert (rc >= 0, -rc);
     if (rc == 1 && !nn_thread_current (&self->cp->worker))
         nn_efd_signal (&self->cp->efd);
@@ -342,7 +342,7 @@
         return rc;
     }
     nn_mutex_init (&self->sync);
-    nn_timeout_init (&self->timeout);
+    nn_timerset_init (&self->timeout);
     nn_queue_init (&self->opqueue);
     nn_mutex_init (&self->events_sync);
     nn_queue_init (&self->events);
@@ -379,7 +379,7 @@
     nn_mutex_term (&self->events_sync);
     nn_poller_term (&self->poller);
     nn_efd_term (&self->efd);
-    nn_timeout_term (&self->timeout);
+    nn_timerset_term (&self->timeout);
     nn_mutex_term (&self->sync);
 }
 
@@ -400,7 +400,7 @@
     int timeout;
     struct nn_queue_item *qit;
     struct nn_cp_op_hndl *ophndl;
-    struct nn_timeout_hndl *tohndl;
+    struct nn_timerset_hndl *tohndl;
     struct nn_timer *timer;
     int op;
     struct nn_poller_hndl *phndl;
@@ -417,7 +417,7 @@
     while (1) {
 
         /*  Compute the time interval till next timer expiration. */
-        timeout = nn_timeout_timeout (&self->timeout);
+        timeout = nn_timerset_timeout (&self->timeout);
 
         /*  Wait for new events and/or timeouts. */
         nn_mutex_unlock (&self->sync);
@@ -466,7 +466,7 @@
 
         /*  Process any expired timers. */
         while (1) {
-            rc = nn_timeout_event (&self->timeout, &tohndl);
+            rc = nn_timerset_event (&self->timeout, &tohndl);
             if (rc == -EAGAIN)
                 break;
             errnum_assert (rc == 0, -rc);
diff --git a/src/utils/aio_win.inc b/src/utils/aio_win.inc
index c72ec04..516493b 100644
--- a/src/utils/aio_win.inc
+++ b/src/utils/aio_win.inc
@@ -35,13 +35,13 @@
 {
     self->sink = sink;
     self->cp = cp;
-    nn_timeout_hndl_init (&self->hndl);
+    nn_timerset_hndl_init (&self->hndl);
 }
 
 void nn_timer_term (struct nn_timer *self)
 {
     nn_timer_stop (self);
-    nn_timeout_hndl_term (&self->hndl);
+    nn_timerset_hndl_term (&self->hndl);
 }
 
 void nn_timer_start (struct nn_timer *self, int timeout)
@@ -50,10 +50,10 @@
     BOOL brc;
 
     /*  If the timer is active, cancel it first. */
-    if (nn_timeout_hndl_isactive (&self->hndl))
+    if (nn_timerset_hndl_isactive (&self->hndl))
         nn_timer_stop (self);
 
-    rc = nn_timeout_add (&self->cp->timeout, timeout, &self->hndl);
+    rc = nn_timerset_add (&self->cp->timeout, timeout, &self->hndl);
     errnum_assert (rc >= 0, -rc);
 
     if (rc == 1 && !nn_thread_current (&self->cp->worker)) {
@@ -69,10 +69,10 @@
     BOOL brc;
 
     /*  If the timer is not active, do nothing. */
-    if (!nn_timeout_hndl_isactive (&self->hndl))
+    if (!nn_timerset_hndl_isactive (&self->hndl))
          return;
 
-    rc = nn_timeout_rm (&self->cp->timeout, &self->hndl);
+    rc = nn_timerset_rm (&self->cp->timeout, &self->hndl);
     errnum_assert (rc >= 0, -rc);
     if (rc == 1 && !nn_thread_current (&self->cp->worker)) {
         brc = PostQueuedCompletionStatus (self->cp->hndl, 0,
@@ -210,7 +210,7 @@
 int nn_cp_init (struct nn_cp *self)
 {
     nn_mutex_init (&self->sync);
-    nn_timeout_init (&self->timeout);
+    nn_timerset_init (&self->timeout);
 
     /*  Create system-level completion port. */
     self->hndl = CreateIoCompletionPort (INVALID_HANDLE_VALUE, NULL, 0, 0);
@@ -240,7 +240,7 @@
     /*  Deallocate the resources. */
     brc = CloseHandle (self->hndl);
     win_assert (brc);
-    nn_timeout_term (&self->timeout);
+    nn_timerset_term (&self->timeout);
     nn_mutex_term (&self->sync);
 }
 
@@ -263,7 +263,7 @@
     DWORD nbytes;
     ULONG_PTR key;
     LPOVERLAPPED olpd;
-    struct nn_timeout_hndl *tohndl;
+    struct nn_timerset_hndl *tohndl;
     struct nn_timer *timer;
     struct nn_event *event;
     struct nn_usock_op *op;
@@ -274,7 +274,7 @@
     while (1) {
 
         /*  Compute the time interval till next timer expiration. */
-        timeout = nn_timeout_timeout (&self->timeout);
+        timeout = nn_timerset_timeout (&self->timeout);
 
         /*  Wait for new events and/or timeouts. */
         /*  TODO: In theory we may gain some performance by getting multiple
@@ -289,7 +289,7 @@
 
         /*  Process any expired timers. */
         while (1) {
-            rc = nn_timeout_event (&self->timeout, &tohndl);
+            rc = nn_timerset_event (&self->timeout, &tohndl);
             if (rc == -EAGAIN)
                 break;
             errnum_assert (rc == 0, -rc);
diff --git a/src/utils/timeout.c b/src/utils/timerset.c
similarity index 78%
rename from src/utils/timeout.c
rename to src/utils/timerset.c
index 0f16d33..9639bb2 100644
--- a/src/utils/timeout.c
+++ b/src/utils/timerset.c
@@ -1,5 +1,5 @@
 /*
-    Copyright (c) 2012 250bpm s.r.o.
+    Copyright (c) 2012-2013 250bpm s.r.o.
 
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"),
@@ -20,28 +20,28 @@
     IN THE SOFTWARE.
 */
 
-#include "timeout.h"
+#include "timerset.h"
 #include "fast.h"
 #include "cont.h"
 #include "err.h"
 
-void nn_timeout_init (struct nn_timeout *self)
+void nn_timerset_init (struct nn_timerset *self)
 {
     nn_clock_init (&self->clock);
     nn_list_init (&self->timeouts);
 }
 
-void nn_timeout_term (struct nn_timeout *self)
+void nn_timerset_term (struct nn_timerset *self)
 {
     nn_list_term (&self->timeouts);
     nn_clock_term (&self->clock);
 }
 
-int nn_timeout_add (struct nn_timeout *self, int timeout,
-    struct nn_timeout_hndl *hndl)
+int nn_timerset_add (struct nn_timerset *self, int timeout,
+    struct nn_timerset_hndl *hndl)
 {
     struct nn_list_item *it;
-    struct nn_timeout_hndl *ith;
+    struct nn_timerset_hndl *ith;
     int first;
 
     /*  Compute the instant when the timeout will be due. */
@@ -51,7 +51,7 @@
     for (it = nn_list_begin (&self->timeouts);
           it != nn_list_end (&self->timeouts);
           it = nn_list_next (&self->timeouts, it)) {
-        ith = nn_cont (it, struct nn_timeout_hndl, list);
+        ith = nn_cont (it, struct nn_timerset_hndl, list);
         if (hndl->timeout < ith->timeout)
             break;
     }
@@ -63,7 +63,7 @@
     return first;
 }
 
-int nn_timeout_rm (struct nn_timeout *self, struct nn_timeout_hndl *hndl)
+int nn_timerset_rm (struct nn_timerset *self, struct nn_timerset_hndl *hndl)
 {
     int first;
 
@@ -78,7 +78,7 @@
     return first;
 }
 
-int nn_timeout_timeout (struct nn_timeout *self)
+int nn_timerset_timeout (struct nn_timerset *self)
 {
     int timeout;
 
@@ -86,13 +86,13 @@
         return -1;
 
     timeout = (int) (nn_cont (nn_list_begin (&self->timeouts),
-        struct nn_timeout_hndl, list)->timeout - nn_clock_now (&self->clock));
+        struct nn_timerset_hndl, list)->timeout - nn_clock_now (&self->clock));
     return timeout < 0 ? 0 : timeout;
 }
 
-int nn_timeout_event (struct nn_timeout *self, struct nn_timeout_hndl **hndl)
+int nn_timerset_event (struct nn_timerset *self, struct nn_timerset_hndl **hndl)
 {
-    struct nn_timeout_hndl *first;
+    struct nn_timerset_hndl *first;
 
     /*  If there's no timeout, there's no event to report. */
     if (nn_fast (nn_list_empty (&self->timeouts)))
@@ -100,7 +100,7 @@
 
     /*  If no timeout have expired yet, there's no event to return. */
     first = nn_cont (nn_list_begin (&self->timeouts),
-        struct nn_timeout_hndl, list);
+        struct nn_timerset_hndl, list);
     if (first->timeout > nn_clock_now (&self->clock))
         return -EAGAIN;
 
@@ -111,17 +111,17 @@
     return 0;
 }
 
-void nn_timeout_hndl_init (struct nn_timeout_hndl *self)
+void nn_timerset_hndl_init (struct nn_timerset_hndl *self)
 {
     nn_list_item_init (&self->list);
 }
 
-void nn_timeout_hndl_term (struct nn_timeout_hndl *self)
+void nn_timerset_hndl_term (struct nn_timerset_hndl *self)
 {
     nn_list_item_term (&self->list);
 }
 
-int nn_timeout_hndl_isactive (struct nn_timeout_hndl *self)
+int nn_timerset_hndl_isactive (struct nn_timerset_hndl *self)
 {
     return nn_list_item_isinlist (&self->list);
 }
diff --git a/src/utils/timeout.h b/src/utils/timerset.h
similarity index 65%
rename from src/utils/timeout.h
rename to src/utils/timerset.h
index c105232..ec94df1 100644
--- a/src/utils/timeout.h
+++ b/src/utils/timerset.h
@@ -1,5 +1,5 @@
 /*
-    Copyright (c) 2012 250bpm s.r.o.
+    Copyright (c) 2012-2013 250bpm s.r.o.
 
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"),
@@ -20,8 +20,8 @@
     IN THE SOFTWARE.
 */
 
-#ifndef NN_TIMEOUT_INCLUDED
-#define NN_TIMEOUT_INCLUDED
+#ifndef NN_TIMERSET_INCLUDED
+#define NN_TIMERSET_INCLUDED
 
 #include "clock.h"
 #include "list.h"
@@ -29,27 +29,27 @@
 /*  This class stores a list of timeouts and reports the next one to expire
     along with the time till it happens. */
 
-struct nn_timeout_hndl {
+struct nn_timerset_hndl {
     struct nn_list_item list;
     uint64_t timeout;
 };
 
-struct nn_timeout {
+struct nn_timerset {
     struct nn_clock clock;
     struct nn_list timeouts;
 };
 
-void nn_timeout_init (struct nn_timeout *self);
-void nn_timeout_term (struct nn_timeout *self);
-int nn_timeout_add (struct nn_timeout *self, int timeout,
-    struct nn_timeout_hndl *hndl);
-int nn_timeout_rm (struct nn_timeout *self, struct nn_timeout_hndl *hndl);
-int nn_timeout_timeout (struct nn_timeout *self);
-int nn_timeout_event (struct nn_timeout *self, struct nn_timeout_hndl **hndl);
+void nn_timerset_init (struct nn_timerset *self);
+void nn_timerset_term (struct nn_timerset *self);
+int nn_timerset_add (struct nn_timerset *self, int timeout,
+    struct nn_timerset_hndl *hndl);
+int nn_timerset_rm (struct nn_timerset *self, struct nn_timerset_hndl *hndl);
+int nn_timerset_timeout (struct nn_timerset *self);
+int nn_timerset_event (struct nn_timerset *self, struct nn_timerset_hndl **hndl);
 
-void nn_timeout_hndl_init (struct nn_timeout_hndl *self);
-void nn_timeout_hndl_term (struct nn_timeout_hndl *self);
-int nn_timeout_hndl_isactive (struct nn_timeout_hndl *self);
+void nn_timerset_hndl_init (struct nn_timerset_hndl *self);
+void nn_timerset_hndl_term (struct nn_timerset_hndl *self);
+int nn_timerset_hndl_isactive (struct nn_timerset_hndl *self);
 
 #endif