MySQL 8.0.39
Source Code Documentation
ut0wqueue.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2006, 2024, 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 designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/** @file include/ut0wqueue.h
29 A work queue
30
31 Created 4/26/2006 Osku Salerma
32 ************************************************************************/
33
34/** A Work queue. Threads can add work items to the queue and other threads can
35 wait for work items to be available and take them off the queue for
36 processing.
37 ************************************************************************/
38
39#ifndef IB_WORK_QUEUE_H
40#define IB_WORK_QUEUE_H
41
42#include "mem0mem.h"
43#include "sync0sync.h"
44#include "ut0list.h"
45
46// Forward declaration
47struct ib_list_t;
48struct ib_wqueue_t;
49
50/** Create a new work queue.
51 @return work queue */
53
54/** Free a work queue. */
55void ib_wqueue_free(ib_wqueue_t *wq); /*!< in: work queue */
56
57/** Add a work item to the queue.
58@param[in] wq Work queue
59@param[in] item Work item
60@param[in] heap Memory heap to use for allocating the list node */
61void ib_wqueue_add(ib_wqueue_t *wq, void *item, mem_heap_t *heap);
62
63/** read total number of work item to the queue.
64@param[in] wq Work queue
65@return total count of work item in the queue */
67
68/********************************************************************
69Check if queue is empty. */
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 for specified time. */
78 /* out: work item or NULL on timeout*/
79 ib_wqueue_t *wq, /* in: work queue */
80 std::chrono::microseconds wait); /* in: wait time */
81
82#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:63
Definition: ut0list.h:98
Definition: ut0wqueue.cc:43
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:302
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:82
bool ib_wqueue_is_empty(const ib_wqueue_t *wq)
Definition: ut0wqueue.cc:141
void * ib_wqueue_timedwait(ib_wqueue_t *wq, std::chrono::microseconds wait)
Definition: ut0wqueue.cc:102
ib_wqueue_t * ib_wqueue_create()
Create a new work queue.
Definition: ut0wqueue.cc:52
uint64_t ib_wqueue_get_count(ib_wqueue_t *wq)
read total number of work item to the queue.
Definition: ut0wqueue.cc:92
void ib_wqueue_free(ib_wqueue_t *wq)
Free a work queue.
Definition: ut0wqueue.cc:69