diff options
author | Simo Sorce <simo@redhat.com> | 2012-01-18 11:35:03 -0500 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2012-01-18 11:35:03 -0500 |
commit | 6ca28bbf8523713e34ed2a7378e21f23cf64e298 (patch) | |
tree | 795e9a23510be415e115bdd488a28c8c507115e2 /proxy/src/gp_utils.h | |
parent | 1d62ecb4261c30c8312f765f81ad9b4c75334a33 (diff) | |
download | gss-proxy-6ca28bbf8523713e34ed2a7378e21f23cf64e298.tar.gz gss-proxy-6ca28bbf8523713e34ed2a7378e21f23cf64e298.tar.xz gss-proxy-6ca28bbf8523713e34ed2a7378e21f23cf64e298.zip |
Organize workers in free and busy lists
This avoids going through an array to chase free threads, so that assigning
work is O(1) instead of O(n).
Will also make easier to later change the number of available workers
dynamically.
Diffstat (limited to 'proxy/src/gp_utils.h')
-rw-r--r-- | proxy/src/gp_utils.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/proxy/src/gp_utils.h b/proxy/src/gp_utils.h index 47d766d..38ca400 100644 --- a/proxy/src/gp_utils.h +++ b/proxy/src/gp_utils.h @@ -33,6 +33,31 @@ #define _(STRING) gettext(STRING) +/* add element to list head */ +#define LIST_ADD(list, elem) do { \ + elem->prev = NULL; \ + elem->next = list; \ + if (list) { \ + list->prev = elem; \ + } \ + list = elem; \ +} while (0) + +/* remove element from list */ +#define LIST_DEL(list, elem) do { \ + if (elem->next) { \ + elem->next->prev = elem->prev; \ + } \ + if (elem->prev) { \ + elem->prev->next = elem->next; \ + } \ + if (list == elem) { \ + list = elem->next; \ + } \ + elem->prev = NULL; \ + elem->next = NULL; \ +} while (0) + struct gp_config { char *config_file; /* gssproxy configuration file */ bool daemonize; /* let gssproxy daemonize */ |