YSTest: Task.h 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
Task.h
浏览该文件的文档.
1 /*
2 © 2013 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YSL_INC_Core_Task_h_
29 #define YSL_INC_Core_Task_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Core_YApplication
33
34 namespace YSLib
35 {
36
41 template<typename _fCallable>
42 inline void
43 PostTask(_fCallable&& f, Messaging::Priority prior = Messaging::NormalPriority)
44 {
45 PostMessage<SM_Task>(prior, yforward(f));
46 }
47
48 namespace Messaging
49 {
50
55 template<typename _fCallable>
56 void
57 Renew(_fCallable update, Priority prior = Messaging::NormalPriority)
58 {
59 PostTask([=]{
60 if(update())
61 Messaging::Renew(update, prior);
62 }, prior);
63 }
64
69 template<typename _fCallable>
70 class GAutoTask
71 {
72 static_assert(std::is_object<_fCallable>::value,
73 "Callable object type is needed.");
74 public:
76 using Callable = _fCallable;
77
78 _fCallable Update;
79 Priority TaskPriority;
80
82 template<typename _fUpdater>
83 GAutoTask(_fUpdater f, Priority prior = NormalPriority)
84 : Update(f), TaskPriority(prior)
85 {}
86
87 virtual DefDeDtor(GAutoTask)
88
89
90 DefCvt(ynothrow, Callable&, *this)
92 DefCvt(const ynothrow, const Callable&, *this)
93 };
94
95 } // namespace Messaging;
96
97 } // namespace YSLib;
98
99 #endif
100
YModules.h
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:722
YSLib::Messaging::GAutoTask::Callable
_fCallable Callable
Definition: Task.h:76
YSLib::Messaging::GAutoTask::Update
_fCallable Update
Definition: Task.h:78
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
YSLib::Messaging::Renew
void Renew(_fCallable update, Priority prior=Messaging::NormalPriority)
按更新条件和优先级通过消息队列部署任务。
Definition: Task.h:57
YSLib::Messaging::GAutoTask::DefDeDtor
virtual DefDeDtor(GAutoTask) DefCvt(ynothrow
YSLib::UI::f
_tWidget _fCallable && f
Definition: ywgtevt.h:597
YSLib::Messaging::NormalPriority
yconstexpr Priority NormalPriority(0x80)
默认消息优先级。
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:164
YSLib::Messaging::GAutoTask::TaskPriority
Priority TaskPriority
Definition: Task.h:79
YSLib::Messaging::GAutoTask
可执行更新操作的任务。
Definition: Task.h:70
YSLib::Messaging::GAutoTask::GAutoTask
GAutoTask(_fUpdater f, Priority prior=NormalPriority)
Definition: Task.h:83
YSLib::PostTask
void PostTask(_fCallable &&f, Messaging::Priority prior=Messaging::NormalPriority)
通过消息队列部署后任务。
Definition: Task.h:43
YSLib::Messaging::Priority
u8 Priority
消息优先级。
Definition: ymsg.h:52