-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build a async task schedule framework
- Loading branch information
fs
committed
Mar 7, 2024
1 parent
f046006
commit 1a6b1d2
Showing
6 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
project(async_task) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
# 添加src目录 | ||
add_subdirectory(src) | ||
|
||
# 启用测试 | ||
# enable_testing() | ||
# add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## how to run | ||
mkdir build | ||
cd build && cmake .. && make | ||
|
||
## how to test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
file(GLOB_RECURSE SOURCE_FILES "*.cpp") | ||
|
||
add_library(async_task SHARED ${SOURCE_FILES}) | ||
|
||
# 指定这个库的头文件路径 | ||
target_include_directories(async_task PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef ASYNC_TASK_H | ||
#define ASYNC_TASK_H | ||
|
||
#include <string> | ||
#include <memory> | ||
#include <functional> | ||
#include <atomic> | ||
#include "utils/utils_define.h" | ||
|
||
namespace async_framework { | ||
/** | ||
* @brief 任务参数类 | ||
* | ||
* 用于存储任务相关的参数。 | ||
*/ | ||
class TaskParam { | ||
public: | ||
virtual ~TaskParam() = default; | ||
}; | ||
|
||
class VoidTaskParam : public TaskParam { | ||
public: | ||
VoidTaskParam() = default; | ||
virtual ~VoidTaskParam() = default; | ||
|
||
static VoidTaskParam& value() { | ||
return *pointer(); | ||
} | ||
static std::shared_ptr< VoidTaskParam > pointer() { | ||
static std::shared_ptr< VoidTaskParam > s_void_param = std::make_shared< VoidTaskParam >(); | ||
return s_void_param; | ||
} | ||
private: | ||
DISALLOW_COPY_AND_ASSIGN(VoidTaskParam); | ||
|
||
}; | ||
|
||
class task { | ||
public: | ||
}; | ||
|
||
} | ||
|
||
|
||
#endif |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef UTILS_DEFINE_H | ||
#define UTILS_DEFINE_H | ||
|
||
#ifndef DISALLOW_COPY_AND_ASSIGN | ||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | ||
TypeName(const TypeName&) = delete; \ | ||
TypeName& operator=(const TypeName&) = delete | ||
#endif | ||
|
||
#endif // BAIDU_AD2_SIM_FRAMEWORK_INLUCDE_GLOBAL_DEFINE_H |