MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
simple_queue.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See the Mulan PSL v2 for more details. */
10
11//
12// Created by Wangyunlai on 2023/01/11.
13//
14
15#pragma once
16
17#include "common/queue/queue.h"
18#include "common/lang/mutex.h"
19#include "common/lang/queue.h"
20
21namespace common {
22
31template <typename T>
32class SimpleQueue : public Queue<T>
33{
34public:
35 using value_type = T;
36
37public:
38 SimpleQueue() : Queue<T>() {}
39 virtual ~SimpleQueue() {}
40
42 int push(value_type &&value) override;
44 int pop(value_type &value) override;
46 int size() const override;
47
48private:
49 mutex mutex_;
50 queue<value_type> queue_;
51};
52
53} // namespace common
54
55#include "common/queue/simple_queue.ipp"
任务队列接口
Definition: queue.h:31
一个十分简单的线程安全的任务队列
Definition: simple_queue.h:33
int size() const override
当前队列中任务的数量
Definition: simple_queue.ipp:39
int pop(value_type &value) override
从队列中取出一个任务
Definition: simple_queue.ipp:26
int push(value_type &&value) override
Definition: simple_queue.ipp:18