libdatatypes 0.3.2
Abstract datatypes for C.
Loading...
Searching...
No Matches
asyncqueue.h
Go to the documentation of this file.
1/***************************************************************************
2 begin........: June 2012
3 copyright....: Sebastian Fedrau
4 email........: sebastian.fedrau@gmail.com
5 ***************************************************************************/
6
7/***************************************************************************
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License v3 as published by
10 the Free Software Foundation.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License v3 for more details.
16 ***************************************************************************/
22#ifdef WITH_PTHREAD
23
24#ifndef ASYNCQUEUE_H
25#define ASYNCQUEUE_H
26
27#include <pthread.h>
28
29#include "datatypes.h"
30
35typedef struct
36{
38 pthread_mutex_t mutex;
40 pthread_cond_t cond;
44 size_t waiting;
46
56
65void async_queue_init(AsyncQueue *queue, CompareFunc compare, FreeFunc free, Pool *pool);
66
73
79void async_queue_free(AsyncQueue *queue);
80
87void async_queue_push(AsyncQueue *queue, void *data);
88
96bool async_queue_pop(AsyncQueue *queue, void *data);
97
106bool async_queue_pop_timeout(AsyncQueue *queue, void *data, uint32_t ms);
107
113void async_queue_clear(AsyncQueue *queue);
114
121size_t async_queue_count(AsyncQueue *queue);
122
123#endif /* __ASYNCQUEUE_H__ */
124
125#endif /* WITH_PTHREAD */
126
void async_queue_init(AsyncQueue *queue, CompareFunc compare, FreeFunc free, Pool *pool)
Definition asyncqueue.c:61
size_t waiting
Definition asyncqueue.h:44
pthread_cond_t cond
Definition asyncqueue.h:40
AsyncQueue * async_queue_new(CompareFunc compare, FreeFunc free, Pool *pool)
Definition asyncqueue.c:33
pthread_mutex_t mutex
Definition asyncqueue.h:38
Queue queue
Definition asyncqueue.h:42
void async_queue_free(AsyncQueue *queue)
Definition asyncqueue.c:92
size_t async_queue_count(AsyncQueue *queue)
Definition asyncqueue.c:217
void async_queue_clear(AsyncQueue *queue)
Definition asyncqueue.c:205
void async_queue_destroy(AsyncQueue *queue)
Definition asyncqueue.c:74
bool async_queue_pop_timeout(AsyncQueue *queue, void *data, uint32_t ms)
Definition asyncqueue.c:199
void async_queue_push(AsyncQueue *queue, void *data)
Definition asyncqueue.c:103
bool async_queue_pop(AsyncQueue *queue, void *data)
Definition asyncqueue.c:191
Asynchronous communication between threads.
Definition asyncqueue.h:36
int32_t(* CompareFunc)(const void *a, const void *b)
Definition compare.h:30
General declarations.
void(* FreeFunc)(void *p)
Definition datatypes.h:33
Singly-linked list.
Definition slist.h:49
Allocate groups of equal-sized chunks of memory.
Definition pool.h:33