MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_task.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_TASK_H_1622688410
12#define INCGUARD_MGL_TASK_H_1622688410
13
14#include <mgl/mgl_environment.h>
15#include <mgl/task/mgl_task_default_task_node.h>
18
19namespace MGL::Task
20{
21bool Initialize(size_t capacity, const InitializeDescriptor &descriptor) noexcept;
22
23/* ------------------------------------------------------------------------- */
30/* ------------------------------------------------------------------------- */
31template <class TaskClass, class... Args>
32constexpr WeakNode Create(Args... args) noexcept
33{
34 auto &nodeList = NodeList::GetInstance();
35 if (!nodeList.HasFreeNode())
36 {
37 return {};
38 }
39
40 auto index = nodeList.Add(STL::make_unique<TaskClass>(args...));
41
42 return WeakNode(index);
43}
44
45/* ------------------------------------------------------------------------- */
49/* ------------------------------------------------------------------------- */
50inline void Execute() noexcept
51{
53}
54
55/* ------------------------------------------------------------------------- */
61/* ------------------------------------------------------------------------- */
62inline size_t Kill(ResideLevel resideLevel = ResideLevel::NoResident) noexcept
63{
64 return NodeList::GetInstance().Kill(resideLevel);
65}
66
67/* ------------------------------------------------------------------------- */
75/* ------------------------------------------------------------------------- */
76template <typename TaskIDType>
77inline size_t Kill(TaskIDType identifier, ResideLevel resideLevel = ResideLevel::NoResident) noexcept
78{
79 return NodeList::GetInstance().Kill(Identifier(identifier), resideLevel);
80}
81
82/* ------------------------------------------------------------------------- */
87/* ------------------------------------------------------------------------- */
88inline size_t DestroyThemAll() noexcept
89{
90 return Kill(ResideLevel::Max);
91}
92
93/* ------------------------------------------------------------------------- */
98/* ------------------------------------------------------------------------- */
99inline size_t GetCount() noexcept
100{
102}
103
104/* ------------------------------------------------------------------------- */
111/* ------------------------------------------------------------------------- */
112template <typename TaskIDType>
113inline size_t GetCount(TaskIDType identifier) noexcept
114{
115 return NodeList::GetInstance().GetCount(identifier);
116}
117
118/* ------------------------------------------------------------------------- */
125/* ------------------------------------------------------------------------- */
126template <typename TaskIDType>
127STL::vector<WeakNode> Find(TaskIDType identifier) noexcept
128{
130
131 NodeList::GetInstance().GetNodeArray(result, Identifier(identifier));
132
133 return result;
134}
135
136/* ------------------------------------------------------------------------- */
143/* ------------------------------------------------------------------------- */
144template <typename EventIDType>
145inline void NotifyEvent(EventIDType eventID, void *argument = nullptr) noexcept
146{
148}
149
150/* ------------------------------------------------------------------------- */
159/* ------------------------------------------------------------------------- */
160template <typename TaskIDType, typename EventIDType>
161inline void NotifyEvent(TaskIDType identifier, EventIDType eventID, void *argument = nullptr) noexcept
162{
163 NodeList::GetInstance().NotifyEvent(Identifier(identifier), EventIdentifier(eventID), argument);
164}
165
166} // namespace MGL::Task
167
168#endif // INCGUARD_MGL_TASK_H_1622688410
169
170// vim: et ts=4 sw=4 sts=4
static NodeList & GetInstance() noexcept
Definition mgl_singleton.h:74
void NotifyEvent(EventIdentifier eventIdentifier, void *arg) noexcept
タスクへのイベント通知
Definition mgl_task_node_list.cc:353
size_t Kill(ResideLevel resideLevel=ResideLevel::NoResident) noexcept
全てのノードに削除要求を発行する
Definition mgl_task_node_list.cc:220
size_t GetCount() noexcept
全体のノード数を取得
Definition mgl_task_node_list.cc:258
void GetNodeArray(STL::vector< WeakNode > &weakNodeArray, Identifier identifier) noexcept
ノードの配列を取得
Definition mgl_task_node_list.cc:332
void Execute() noexcept
実行
Definition mgl_task_node_list.cc:137
弱参照タスクノード
Definition mgl_task_weak_node.h:20
MGL 環境定義
bool Initialize(InitializerDelegate &initializer, MakeAppDelegateFunction makeAppDelegate) noexcept
MGL初期化処理
Definition mgl_initialize.cc:67
std::vector< T, Allocator< T > > vector
std::vectorの代替
Definition mgl_stl_containers.h:51
size_t GetCount() noexcept
現在のタスクの総数を取得
Definition mgl_task.h:99
size_t DestroyThemAll() noexcept
常駐プライオリティを無視して全てのタスクを削除
Definition mgl_task.h:88
size_t Kill(ResideLevel resideLevel=ResideLevel::NoResident) noexcept
全てのタスクに削除要求を発行
Definition mgl_task.h:62
void Execute() noexcept
タスクの実行
Definition mgl_task.h:50
void NotifyEvent(EventIDType eventID, void *argument=nullptr) noexcept
タスクへのイベント通知
Definition mgl_task.h:145
constexpr WeakNode Create(Args... args) noexcept
タスクの生成
Definition mgl_task.h:32
STL::vector< WeakNode > Find(TaskIDType identifier) noexcept
タスクを検索
Definition mgl_task.h:127
ResideLevel
常駐レベル
Definition mgl_task_defs.h:109
uint32_t EventIdentifier
イベントIDを表す型
Definition mgl_task_defs.h:105
MGL タスクノードのリスト
MGL 弱参照タスクノード