~drizzle-trunk/drizzle/development

1 by brian
clean slate
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
4
processing.
5
6
************************************************************************/
7
8
#ifndef IB_WORK_QUEUE_H
9
#define IB_WORK_QUEUE_H
10
11
#include "ut0list.h"
12
#include "mem0mem.h"
13
#include "os0sync.h"
14
#include "sync0types.h"
15
16
typedef struct ib_wqueue_struct ib_wqueue_t;
17
18
/********************************************************************
19
Create a new work queue. */
20
21
ib_wqueue_t*
22
ib_wqueue_create(void);
23
/*===================*/
24
			/* out: work queue */
25
26
/********************************************************************
27
Free a work queue. */
28
29
void
30
ib_wqueue_free(
31
/*===========*/
32
	ib_wqueue_t*	wq);	/* in: work queue */
33
34
/********************************************************************
35
Add a work item to the queue. */
36
37
void
38
ib_wqueue_add(
39
/*==========*/
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
43
				list node */
44
45
/********************************************************************
46
Wait for a work item to appear in the queue. */
47
48
void*
49
ib_wqueue_wait(
50
				/* out: work item */
51
	ib_wqueue_t*	wq);	/* in: work queue */
52
53
/* 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 */
58
};
59
60
#endif