1/*****************************************************************************
2
3Copyright (c) 2006, 2014, Oracle and/or its affiliates. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc.,
1551 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16
17*****************************************************************************/
18
19/*******************************************************************//**
20@file include/ut0wqueue.h
21A work queue
22
23Created 4/26/2006 Osku Salerma
24************************************************************************/
25
26/*******************************************************************//**
27A Work queue. Threads can add work items to the queue and other threads can
28wait for work items to be available and take them off the queue for
29processing.
30************************************************************************/
31
32#ifndef IB_WORK_QUEUE_H
33#define IB_WORK_QUEUE_H
34
35#include "ut0list.h"
36#include "mem0mem.h"
37
38// Forward declaration
39struct ib_list_t;
40struct ib_wqueue_t;
41
42/****************************************************************//**
43Create a new work queue.
44@return work queue */
45ib_wqueue_t*
46ib_wqueue_create();
47/*===============*/
48
49/****************************************************************//**
50Free a work queue. */
51void
52ib_wqueue_free(
53/*===========*/
54 ib_wqueue_t* wq); /*!< in: work queue */
55
56/****************************************************************//**
57Add a work item to the queue. */
58void
59ib_wqueue_add(
60/*==========*/
61 ib_wqueue_t* wq, /*!< in: work queue */
62 void* item, /*!< in: work item */
63 mem_heap_t* heap); /*!< in: memory heap to use for
64 allocating the list node */
65
66/********************************************************************
67Check if queue is empty. */
68ibool
69ib_wqueue_is_empty(
70/*===============*/
71 /* out: TRUE if queue empty
72 else FALSE */
73 const ib_wqueue_t* wq); /* in: work queue */
74
75/****************************************************************//**
76Wait for a work item to appear in the queue.
77@return work item */
78void*
79ib_wqueue_wait(
80/*===========*/
81 ib_wqueue_t* wq); /*!< in: work queue */
82
83/********************************************************************
84Wait for a work item to appear in the queue for specified time. */
85void*
86ib_wqueue_timedwait(
87/*================*/
88 /* out: work item or NULL on timeout*/
89 ib_wqueue_t* wq, /* in: work queue */
90 ib_time_t wait_in_usecs); /* in: wait time in micro seconds */
91
92/********************************************************************
93Return first item on work queue or NULL if queue is empty
94@return work item or NULL */
95void*
96ib_wqueue_nowait(
97/*=============*/
98 ib_wqueue_t* wq); /*<! in: work queue */
99/********************************************************************
100Get number of items on queue.
101@return number of items on queue */
102ulint
103ib_wqueue_len(
104/*==========*/
105 ib_wqueue_t* wq); /*<! in: work queue */
106
107
108#endif /* IB_WORK_QUEUE_H */
109