LeviLamina
Loading...
Searching...
No Matches
TaskGroup.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/file/PathBuffer.h"
7#include "mc/deps/core/threading/Async.h"
8#include "mc/deps/core/threading/IBackgroundTaskOwner.h"
9#include "mc/deps/core/threading/SharedAsync.h"
10#include "mc/deps/core/utility/NonOwnerPointer.h"
11#include "mc/deps/nether_net/ESessionError.h"
12#include "mc/editor/services/playtest/SessionResult.h"
13#include "mc/network/services/signaling/ISignalingServiceConfigProvider.h"
14#include "mc/platform/ErrorInfo.h"
15#include "mc/platform/Result.h"
16#include "mc/platform/brstd/move_only_function.h"
17#include "mc/platform/brstd/promise.h"
18#include "mc/platform/threading/Mutex.h"
19#include "mc/platform/threading/UniqueLock.h"
20#include "mc/resources/TaskGroupState.h"
21#include "mc/server/commands/edu/make_code_fileio/MakeCodeFileResult.h"
22#include "mc/world/level/FileArchiver.h"
23
24// auto generated forward declare list
25// clang-format off
27class Pack;
28class ResourcePack;
29class Scheduler;
30class TaskResult;
31class WorkerPool;
33struct AsyncJoinAllow;
34struct AsyncJoinDeny;
38struct TaskStartInfo;
39namespace Bedrock::Http { class HeaderCollection; }
40namespace Bedrock::Http { class Request; }
41namespace Bedrock::Http { class Response; }
42namespace Bedrock::Http { struct Url; }
43namespace Bedrock::Services { struct AzureGetTokenHttpResponse; }
44namespace Bedrock::Services { struct EnvironmentQueryResponse; }
45namespace Bedrock::Threading { struct CachedAsyncRetry; }
46namespace Json { class Value; }
47namespace JsonRpc { class JsonRpcError; }
48namespace JsonRpc { class TurnConfigResult; }
49namespace MakeCodeFileIO { struct MakeCodeFileIOReadResult; }
50namespace PackCommand { struct PackCommandResult; }
51namespace RepositoryLoading { struct PackModifications; }
52namespace Safety { struct TextFilterResult; }
53// clang-format on
54
55class TaskGroup : public ::IBackgroundTaskOwner {
56public:
57 // TaskGroup inner types declare
58 // clang-format off
59 template<typename T0> class ThenableBase;
60 // clang-format on
61
62 // TaskGroup inner types define
63 template <typename T0>
64 class ThenableBase {};
65
66public:
67 // member variables
68 // NOLINTBEGIN
69 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::Scheduler>> mScheduler;
70 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::WorkerPool>> mWorkers;
71 ::ll::TypedStorage<8, 32, ::std::string> mName;
72 ::ll::TypedStorage<1, 1, bool> mCheckOwnerThread;
73 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mLock;
74 ::ll::TypedStorage<4, 4, ::std::atomic<::TaskGroupState>> mState;
75 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::BackgroundTaskBase>> mTasks;
76 ::ll::TypedStorage<8, 8, uint64> mTaskCount;
77 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::BackgroundTaskBase>> mEnumCurr;
78 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::BackgroundTaskBase>> mEnumNext;
79 ::ll::TypedStorage<8, 16, ::Bedrock::Threading::Async<void>> mResumeTaskHandle;
80 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mResumeTaskMutex;
81 // NOLINTEND
82
83public:
84 // prevent constructor by default
85 TaskGroup();
86
87public:
88 // virtual functions
89 // NOLINTBEGIN
90 virtual ::Bedrock::Threading::Async<void> queue_DEPRECATED(
91 ::TaskStartInfo const& startInfo,
93 ::std::function<void()>&& callback
94 ) /*override*/;
95
96 virtual ::Bedrock::Threading::Async<void> queueSync_DEPRECATED(
97 ::TaskStartInfo const& startInfo,
99 ) /*override*/;
100
101 virtual ~TaskGroup() /*override*/;
102
103 virtual void taskRegister(::std::shared_ptr<::BackgroundTaskBase> task) /*override*/;
104
105 virtual void requeueTask(::std::shared_ptr<::BackgroundTaskBase> task, bool queueImmediate) /*override*/;
106
107 virtual ::TaskGroupState getState() const /*override*/;
108
109 virtual void processCoroutines() /*override*/;
110
111 virtual void taskComplete(::gsl::not_null<::BackgroundTaskBase*> task) /*override*/;
112
113 virtual bool _workerPoolIsAsync() const;
114 // NOLINTEND
115
116public:
117 // member functions
118 // NOLINTBEGIN
119 MCAPI TaskGroup(::WorkerPool& workers, ::Scheduler& context, ::std::string name);
120
121 MCAPI void _doWorkUntil(::Bedrock::Threading::SharedAsync<void> task, ::brstd::promise<void>* workStarted);
122
123 MCAPI void _forAllTasks(
124 ::Bedrock::Threading::UniqueLock<::Bedrock::Threading::Mutex>& lock,
125 ::std::function<void(::std::shared_ptr<::BackgroundTaskBase> const&)> callback
126 );
127
128 MCAPI void _queueInternal(::std::shared_ptr<::BackgroundTaskBase> bgtask);
129
130#ifdef LL_PLAT_C
131 MCAPI uint64 count() const;
132#endif
133
134 MCAPI void disableOwnerThreadChecks();
135
136 MCAPI void flush(::std::function<void()> waitFn);
137
138#ifdef LL_PLAT_C
139 MCAPI uint64 getMaxConcurrency() const;
140#endif
141
142 MCFOLD ::std::string_view getName() const;
143
144 MCAPI ::std::thread::id getOwnerThreadID() const;
145
146 MCAPI ::Scheduler& getScheduler();
147
148 MCAPI bool isEmpty() const;
149
150#ifdef LL_PLAT_C
151 MCAPI void kick(uint count);
152#endif
153
154 MCAPI void pause();
155
156#ifdef LL_PLAT_C
157 MCAPI void resume();
158#endif
159
160 MCAPI void sync_DEPRECATED_ASK_TOMMO(::std::function<void()> waitFn);
161 // NOLINTEND
162
163public:
164 // static functions
165 // NOLINTBEGIN
166 MCAPI static ::IBackgroundTaskOwner* getCurrentTaskGroup();
167
168 MCAPI static ::Bedrock::Threading::Async<void>
169 queueChildSync_DEPRECATED(::TaskStartInfo const& startInfo, ::brstd::move_only_function<::TaskResult()>&& task);
170
171 MCAPI static ::Bedrock::Threading::Async<void> queueChild_DEPRECATED(
172 ::TaskStartInfo const& startInfo,
174 ::std::function<void()>&& callback
175 );
176 // NOLINTEND
177
178public:
179 // constructor thunks
180 // NOLINTBEGIN
181 MCAPI void* $ctor(::WorkerPool& workers, ::Scheduler& context, ::std::string name);
182 // NOLINTEND
183
184public:
185 // destructor thunk
186 // NOLINTBEGIN
187 MCAPI void $dtor();
188 // NOLINTEND
189
190public:
191 // virtual function thunks
192 // NOLINTBEGIN
193 MCAPI ::Bedrock::Threading::Async<void> $queue_DEPRECATED(
194 ::TaskStartInfo const& startInfo,
196 ::std::function<void()>&& callback
197 );
198
199 MCAPI ::Bedrock::Threading::Async<void>
200 $queueSync_DEPRECATED(::TaskStartInfo const& startInfo, ::brstd::move_only_function<::TaskResult()>&& task);
201
202 MCAPI void $taskRegister(::std::shared_ptr<::BackgroundTaskBase> task);
203
204 MCAPI void $requeueTask(::std::shared_ptr<::BackgroundTaskBase> task, bool queueImmediate);
205
206 MCFOLD ::TaskGroupState $getState() const;
207
208 MCAPI void $processCoroutines();
209
210 MCAPI void $taskComplete(::gsl::not_null<::BackgroundTaskBase*> task);
211
212 MCAPI bool $_workerPoolIsAsync() const;
213
214
215 // NOLINTEND
216
217public:
218 // vftables
219 // NOLINTBEGIN
220 MCNAPI static void** $vftable();
221 // NOLINTEND
222};
Definition BackgroundTaskBase.h:16
Definition HeaderCollection.h:7
Definition Request.h:22
Definition Response.h:7
Definition IBackgroundTaskOwner.h:17
Definition JsonRpcError.h:12
Definition TurnConfigResult.h:13
Definition Value.h:16
Definition Pack.h:28
Definition ResourcePack.h:28
Definition Scheduler.h:15
Definition TaskGroup.h:64
static MCAPI void ** $vftable()
Definition TaskResult.h:5
Definition WorkerPool.h:20
Definition WorldPacksHistoryFile.h:12
Definition move_only_function.h:9
STL namespace.
Definition AsyncJoinAllow.h:5
Definition AsyncJoinDeny.h:8
Definition Url.h:7
Definition AzureGetTokenHttpResponse.h:7
Definition EnvironmentQueryResponse.h:12
Definition CachedAsyncRetry.h:7
Definition MakeCodeFileIOReadResult.h:10
Definition MinecraftServiceKeyInfo.h:5
Definition MinecraftServiceKeysMetadata.h:5
Definition PackCommandResult.h:7
Definition PackSourceLoadResult.h:5
Definition PackModifications.h:7
Definition TextFilterResult.h:7
Definition TaskStartInfo.h:5
Definition context.h:5