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
/*******************************************************************//**
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
30
************************************************************************/
32
#ifndef IB_WORK_QUEUE_H
33
#define IB_WORK_QUEUE_H
38
#include "sync0types.h"
40
typedef struct ib_wqueue_struct ib_wqueue_t;
42
/****************************************************************//**
43
Create a new work queue.
47
ib_wqueue_create(void);
48
/*===================*/
50
/****************************************************************//**
56
ib_wqueue_t* wq); /*!< in: work queue */
58
/****************************************************************//**
59
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
69
/****************************************************************//**
70
Wait for a work item to appear in the queue.
76
ib_wqueue_t* wq); /*!< in: 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 */