#if !defined(_DATAQ_H_) #define _DATAQ_H_ 1 #include "mylock.h" typedef struct _data_item { struct _data_item* next; } data_item_t; typedef int (*data_item_match_fn_t)(data_item_t*); /* like data_item_match_fn_t, plus a caller-owned per-scan context */ typedef int (*data_item_match_ctx_fn_t)(data_item_t*, void*); typedef void (*data_item_killer_t)(data_item_t*); typedef struct { data_item_t* head; data_item_t* tail; data_item_killer_t killer; mylock_t lock; } dataq_t; #define DATAQ_EMPTY(q) ((q)->head == NULL) extern int dataq_init(dataq_t*, data_item_killer_t); extern data_item_t* dataq_deq(dataq_t*, data_item_match_fn_t); /* bug-1864: first item matching f, with ctx passed to every f call of this * one scan (under the queue lock) -- lets a matcher remember what it saw * earlier in the same scan */ extern data_item_t* dataq_deq_ctx(dataq_t*, data_item_match_ctx_fn_t, void*); extern int dataq_enq(dataq_t*, data_item_t*); extern void dataq_fini(dataq_t*); #endif