MySQL 8.3.0
Source Code Documentation
ut0wqueue.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2006, 2023, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is also distributed with certain software (including but not
10limited to OpenSSL) that is licensed under separate terms, as designated in a
11particular file or component or in included license documentation. The authors
12of MySQL hereby grant you an additional permission to link the program and
13your derivative works with the separately licensed software that they have
14included with MySQL.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
25*****************************************************************************/
26
27/** @file include/ut0wqueue.h
28 A work queue
29
30 Created 4/26/2006 Osku Salerma
31 ************************************************************************/
32
33/** A Work queue. Threads can add work items to the queue and other threads can
34 wait for work items to be available and take them off the queue for
35 processing.
36 ************************************************************************/
37
38#ifndef IB_WORK_QUEUE_H
39#define IB_WORK_QUEUE_H
40
41#include "mem0mem.h"
42#include "sync0sync.h"
43#include "ut0list.h"
44
45// Forward declaration
46struct ib_list_t;
47struct ib_wqueue_t;
48
49/** Create a new work queue.
50 @return work queue */
52
53/** Free a work queue. */
54void ib_wqueue_free(ib_wqueue_t *wq); /*!< in: work queue */
55
56/** Add a work item to the queue.
57@param[in] wq Work queue
58@param[in] item Work item
59@param[in] heap Memory heap to use for allocating the list node */
60void ib_wqueue_add(ib_wqueue_t *wq, void *item, mem_heap_t *heap);
61
62/** read total number of work item to the queue.
63@param[in] wq Work queue
64@return total count of work item in the queue */
66
67/********************************************************************
68Check if queue is empty. */
70 /* out: true if queue empty
71 else false */
72 const ib_wqueue_t *wq); /* in: work queue */
73
74/********************************************************************
75Wait for a work item to appear in the queue for specified time. */
77 /* out: work item or NULL on timeout*/
78 ib_wqueue_t *wq, /* in: work queue */
79 std::chrono::microseconds wait); /* in: wait time */
80
81#endif /* IB_WORK_QUEUE_H */
The memory management.
static int wait(mysql_cond_t *that, mysql_mutex_t *mutex_arg, const char *, unsigned int)
Definition: mysql_cond_v1_native.cc:62
Definition: ut0list.h:97
Definition: ut0wqueue.cc:42
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:301
Mutex, the basic synchronization primitive.
A double-linked list.
void ib_wqueue_add(ib_wqueue_t *wq, void *item, mem_heap_t *heap)
Add a work item to the queue.
Definition: ut0wqueue.cc:81
bool ib_wqueue_is_empty(const ib_wqueue_t *wq)
Definition: ut0wqueue.cc:140
void * ib_wqueue_timedwait(ib_wqueue_t *wq, std::chrono::microseconds wait)
Definition: ut0wqueue.cc:101
ib_wqueue_t * ib_wqueue_create()
Create a new work queue.
Definition: ut0wqueue.cc:51
uint64_t ib_wqueue_get_count(ib_wqueue_t *wq)
read total number of work item to the queue.
Definition: ut0wqueue.cc:91
void ib_wqueue_free(ib_wqueue_t *wq)
Free a work queue.
Definition: ut0wqueue.cc:68