~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/ut0wqueue.h

Merge Joe, plus I updated the tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 2006, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/*******************************************************************//**
20
 
@file include/ut0wqueue.h
21
 
A work queue
22
 
 
23
 
Created 4/26/2006 Osku Salerma
24
 
************************************************************************/
25
 
 
26
 
/*******************************************************************//**
27
 
A Work queue. Threads can add work items to the queue and other threads can
28
 
wait for work items to be available and take them off the queue for
29
 
processing.
30
 
************************************************************************/
31
 
 
32
 
#ifndef IB_WORK_QUEUE_H
33
 
#define IB_WORK_QUEUE_H
34
 
 
35
 
#include "ut0list.h"
36
 
#include "mem0mem.h"
37
 
#include "os0sync.h"
38
 
#include "sync0types.h"
39
 
 
40
 
typedef struct ib_wqueue_struct ib_wqueue_t;
41
 
 
42
 
/****************************************************************//**
43
 
Create a new work queue.
44
 
@return work queue */
45
 
UNIV_INTERN
46
 
ib_wqueue_t*
47
 
ib_wqueue_create(void);
48
 
/*===================*/
49
 
 
50
 
/****************************************************************//**
51
 
Free a work queue. */
52
 
UNIV_INTERN
53
 
void
54
 
ib_wqueue_free(
55
 
/*===========*/
56
 
        ib_wqueue_t*    wq);    /*!< in: work queue */
57
 
 
58
 
/****************************************************************//**
59
 
Add a work item to the queue. */
60
 
UNIV_INTERN
61
 
void
62
 
ib_wqueue_add(
63
 
/*==========*/
64
 
        ib_wqueue_t*    wq,     /*!< in: work queue */
65
 
        void*           item,   /*!< in: work item */
66
 
        mem_heap_t*     heap);  /*!< in: memory heap to use for allocating the
67
 
                                list node */
68
 
 
69
 
/****************************************************************//**
70
 
Wait for a work item to appear in the queue.
71
 
@return work item */
72
 
UNIV_INTERN
73
 
void*
74
 
ib_wqueue_wait(
75
 
/*===========*/
76
 
        ib_wqueue_t*    wq);    /*!< in: work queue */
77
 
 
78
 
/* Work queue. */
79
 
struct ib_wqueue_struct {
80
 
        mutex_t         mutex;  /*!< mutex protecting everything */
81
 
        ib_list_t*      items;  /*!< work item list */
82
 
        os_event_t      event;  /*!< event we use to signal additions to list */
83
 
};
84
 
 
85
 
#endif