summaryrefslogtreecommitdiffstats
path: root/src/asyncq.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-10-02 20:26:08 +0000
committerLennart Poettering <lennart@poettering.net>2007-10-02 20:26:08 +0000
commit18301dfca56ba8545549e80f84423d83a46c6b64 (patch)
tree28854229666a3054a2985cd040d504e860e0623b /src/asyncq.c
parent0ec595d89d9e1c10cd3f8a3d8dd3a1235c6f5fda (diff)
a lot of minor cleanups
git-svn-id: file:///home/lennart/svn/public/libsydney/trunk@36 9ba3c220-e4d3-45a2-8aa3-73fcc9aff6ce
Diffstat (limited to 'src/asyncq.c')
-rw-r--r--src/asyncq.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/asyncq.c b/src/asyncq.c
index 54d7d5b..ad5b795 100644
--- a/src/asyncq.c
+++ b/src/asyncq.c
@@ -1,3 +1,7 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "sydney.h"
#include "asyncq.h"
#include "malloc.h"
@@ -10,7 +14,7 @@ int sa_asyncq_init(sa_asyncq_t *a, size_t item_size) {
a->last = NULL;
a->item_size = item_size;
-
+
if (!(a->mutex = sa_mutex_new(0)))
return SA_ERROR_OOM;
@@ -19,7 +23,7 @@ int sa_asyncq_init(sa_asyncq_t *a, size_t item_size) {
sa_asyncq_item_t *sa_asyncq_get(sa_asyncq_t *a) {
sa_assert(a);
-
+
sa_mutex_lock(a->mutex);
if ((i = a->unused))
@@ -53,7 +57,7 @@ void sa_asyncq_push(sa_asyncq_t *a, sa_asyncq_item_t *i) {
SA_LLIST_INSERT_AFTER(sa_asyncq_item_t, items, a->items, a->last, i);
else
SA_LLIST_PREPEND(sa_asyncq_item_t, items, a->items, i);
-
+
a->last = i;
sa_mutex_unlock(a->mutex);
@@ -63,7 +67,7 @@ void sa_asyncq_push(sa_asyncq_t *a, sa_asyncq_item_t *i) {
sa_asyncq_item_t sa_asyncq_pop(sa_asyncq_t *a, int wait) {
sa_asyncq_item_t *i;
-
+
sa_assert(a);
if (wait)
@@ -75,10 +79,10 @@ sa_asyncq_item_t sa_asyncq_pop(sa_asyncq_t *a, int wait) {
if ((i = a->items)) {
if (i == a->last)
a->last = NULL;
-
+
SA_LLIST_REMOVE(sa_asyncq_item_t, items, a->items, i);
}
-
+
sa_mutex_unlock(a->mutex);
return i;
@@ -91,7 +95,7 @@ void sa_asyncq_done(sa_asyncq_t *a) {
/* The caller *must* pop all items from the queue before
* destructing us! */
sa_assert(!a->items);
-
+
if (a->mutex)
sa_mutex_free(a->mutex);