1
/***********************************************************************
2
A Work queue. Threads can add work items to the queue and other threads can
3
wait for work items to be available and take them off the queue for
6
************************************************************************/
8
#ifndef IB_WORK_QUEUE_H
9
#define IB_WORK_QUEUE_H
14
#include "sync0types.h"
16
typedef struct ib_wqueue_struct ib_wqueue_t;
18
/********************************************************************
19
Create a new work queue. */
22
ib_wqueue_create(void);
23
/*===================*/
26
/********************************************************************
32
ib_wqueue_t* wq); /* in: work queue */
34
/********************************************************************
35
Add a work item to the queue. */
40
ib_wqueue_t* wq, /* in: work queue */
41
void* item, /* in: work item */
42
mem_heap_t* heap); /* in: memory heap to use for allocating the
45
/********************************************************************
46
Wait for a work item to appear in the queue. */
51
ib_wqueue_t* wq); /* in: work queue */
54
struct ib_wqueue_struct {
55
mutex_t mutex; /* mutex protecting everything */
56
ib_list_t* items; /* work item list */
57
os_event_t event; /* event we use to signal additions to list */