Browse Source

Make create_ckmsgq return a pointer to the generated queue and export the ckdbq functions

master
ckolivas 11 years ago
parent
commit
997a88191c
  1. 6
      src/libckpool.c
  2. 2
      src/libckpool.h

6
src/libckpool.c

@ -77,7 +77,7 @@ void join_pthread(pthread_t thread)
} }
/* Generic function for creating a message queue receiving and parsing thread */ /* Generic function for creating a message queue receiving and parsing thread */
void *ckmsg_queue(void *arg) static void *ckmsg_queue(void *arg)
{ {
ckmsgq_t *ckmsgq = (ckmsgq_t *)arg; ckmsgq_t *ckmsgq = (ckmsgq_t *)arg;
@ -103,7 +103,7 @@ void *ckmsg_queue(void *arg)
return NULL; return NULL;
} }
void create_ckmsgq(const char *name, const void *func) ckmsgq_t *create_ckmsgq(const char *name, const void *func)
{ {
ckmsgq_t *ckmsgq = ckzalloc(sizeof(ckmsgq_t)); ckmsgq_t *ckmsgq = ckzalloc(sizeof(ckmsgq_t));
@ -112,6 +112,8 @@ void create_ckmsgq(const char *name, const void *func)
mutex_init(&ckmsgq->lock); mutex_init(&ckmsgq->lock);
cond_init(&ckmsgq->cond); cond_init(&ckmsgq->cond);
create_pthread(&ckmsgq->pth, ckmsg_queue, ckmsgq); create_pthread(&ckmsgq->pth, ckmsg_queue, ckmsgq);
return ckmsgq;
} }
/* Generic function for adding messages to a ckmsgq linked list and signal the ckmsgq /* Generic function for adding messages to a ckmsgq linked list and signal the ckmsgq

2
src/libckpool.h

@ -280,6 +280,8 @@ struct ckmsgq {
}; };
typedef struct ckmsgq ckmsgq_t; typedef struct ckmsgq ckmsgq_t;
ckmsgq_t *create_ckmsgq(const char *name, const void *func);
void ckmsgq_add(ckmsgq_t *ckmsgq, void *data);
/* No error checking with these, make sure we know they're valid already! */ /* No error checking with these, make sure we know they're valid already! */
static inline void json_strcpy(char *buf, json_t *val, const char *key) static inline void json_strcpy(char *buf, json_t *val, const char *key)

Loading…
Cancel
Save