MiniOB
1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
src
common
thread
runnable.h
1
/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2
miniob is licensed under Mulan PSL v2.
3
You can use this software according to the terms and conditions of the Mulan PSL v2.
4
You may obtain a copy of Mulan PSL v2 at:
5
http://license.coscl.org.cn/MulanPSL2
6
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9
See 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/lang/functional.h"
18
19
namespace
common {
20
25
class
Runnable
26
{
27
public
:
28
Runnable
() =
default
;
29
virtual
~Runnable
() =
default
;
30
31
virtual
void
run() = 0;
32
};
33
38
class
RunnableAdaptor
:
public
Runnable
39
{
40
public
:
41
RunnableAdaptor
(function<
void
()> callable) : callable_(callable) {}
42
43
void
run()
override
{ callable_(); }
44
45
private
:
46
function<void()> callable_;
47
};
48
49
}
// namespace common
common::RunnableAdaptor
可执行对象适配器,方便使用lambda表达式
Definition:
runnable.h:39
common::Runnable
可执行对象接口
Definition:
runnable.h:26
制作者
1.9.5