1
/*****************************************************************************
3
Copyright (c) 2006, 2009, Innobase Oy. All Rights Reserved.
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.
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.
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
17
*****************************************************************************/
19
/*******************************************************************//**
20
@file include/ut0wqueue.h
23
Created 4/26/2006 Osku Salerma
24
************************************************************************/
26
/*******************************************************************//**
1
/***********************************************************************
27
2
A Work queue. Threads can add work items to the queue and other threads can
28
3
wait for work items to be available and take them off the queue for
30
6
************************************************************************/
32
8
#ifndef IB_WORK_QUEUE_H
40
16
typedef struct ib_wqueue_struct ib_wqueue_t;
42
/****************************************************************//**
43
Create a new work queue.
18
/********************************************************************
19
Create a new work queue. */
47
22
ib_wqueue_create(void);
48
23
/*===================*/
50
/****************************************************************//**
26
/********************************************************************
51
27
Free a work queue. */
56
ib_wqueue_t* wq); /*!< in: work queue */
32
ib_wqueue_t* wq); /* in: work queue */
58
/****************************************************************//**
34
/********************************************************************
59
35
Add a work item to the queue. */
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
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
69
/****************************************************************//**
70
Wait for a work item to appear in the queue.
45
/********************************************************************
46
Wait for a work item to appear in the queue. */
76
ib_wqueue_t* wq); /*!< in: work queue */
51
ib_wqueue_t* wq); /* in: work queue */
79
54
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 */
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 */