Remember queue name

This commit is contained in:
Tony Garnock-Jones 2011-01-02 13:58:36 -05:00
parent 9fcffa8083
commit 33e304e7f7
1 changed files with 3 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include "dataq.h"
typedef struct queue_extension_t_ {
sexp_t *name;
sexp_t *backlog_q;
queue_t waiter_q;
hashtable_t subscriptions;
@ -47,6 +48,7 @@ static sexp_t *queue_extend(node_t *n, sexp_t *args) {
if ((sexp_length(args) == 1) && sexp_stringp(sexp_head(args))) {
cmsg_bytes_t name = sexp_data(sexp_head(args));
queue_extension_t *q = calloc(1, sizeof(*q));
q->name = INCREF(sexp_head(args));
q->backlog_q = INCREF(sexp_new_queue());
q->waiter_q = EMPTY_QUEUE(subscription_t, link);
init_hashtable(&q->subscriptions, 5, NULL, NULL);
@ -63,6 +65,7 @@ static sexp_t *queue_extend(node_t *n, sexp_t *args) {
static void queue_destructor(node_t *n) {
queue_extension_t *q = n->extension;
if (q != NULL) { /* can be NULL if queue_extend was given invalid args */
DECREF(q->name, sexp_destructor);
DECREF(q->backlog_q, sexp_destructor);
/* q->waiter_q will be automatically destroyed as part of the destruction of q->subscriptions */
destroy_hashtable(&q->subscriptions);