Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00026
00027
00028
00029
00030
00031
00032 #ifndef __tls_ct_q_h
00033 #define __tls_ct_q_h
00034
00035 #include "sbufq.h"
00036 #include "../../compiler_opt.h"
00037
00038 typedef struct sbuffer_queue tls_ct_q;
00039
00040
00041 #define tls_ct_q_empty(bq) ((bq)==0 || (bq)->first==0)
00042 #define tls_ct_q_non_empty(bq) ((bq) && (bq)->first!=0)
00043
00044
00055 inline static int tls_ct_q_add(tls_ct_q** ct_q, const void* data,
00056 unsigned int size, unsigned int min_buf_size)
00057 {
00058 tls_ct_q* q;
00059
00060 q = *ct_q;
00061 if (likely(q == 0)){
00062 q=shm_malloc(sizeof(tls_ct_q));
00063 if (unlikely(q==0))
00064 goto error;
00065 memset(q, 0, sizeof(tls_ct_q));
00066 *ct_q = q;
00067 }
00068 return sbufq_add(q, data, size, min_buf_size);
00069 error:
00070 return -1;
00071 }
00072
00073
00074
00084 inline static unsigned int tls_ct_q_destroy(tls_ct_q** ct_q)
00085 {
00086 unsigned int ret;
00087
00088 ret = 0;
00089 if (likely(ct_q && *ct_q)) {
00090 ret = sbufq_destroy(*ct_q);
00091 shm_free(*ct_q);
00092 *ct_q = 0;
00093 }
00094 return ret;
00095 }
00096
00097
00098
00124 inline static int tls_ct_q_flush(tls_ct_q** tc_q, int* flags,
00125 int (*flush_f)(void* p1, void* p2,
00126 const void* buf,
00127 unsigned size),
00128 void* flush_p1, void* flush_p2)
00129 {
00130 return *tc_q?sbufq_flush(*tc_q, flags, flush_f, flush_p1, flush_p2):0;
00131 }
00132
00133
00134
00135 #endif
00136
00137