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