LeviLamina
Loading...
Searching...
No Matches
BackgroundWorker.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/container/MovePriorityQueue.h"
7#include "mc/deps/core/threading/BackgroundTaskBase.h"
8#include "mc/deps/core/threading/ITaskExecutionContext.h"
9#include "mc/deps/core/threading/SPSCQueue.h"
10#include "mc/deps/profiler/ThreadFrameType.h"
11
12// auto generated forward declare list
13// clang-format off
15class WorkerPool;
16struct RunTaskOptions;
17namespace Bedrock::Threading { class OSThreadPriority; }
18// clang-format on
19
20class BackgroundWorker : public ::ITaskExecutionContext {
21public:
22 // BackgroundWorker inner types define
23 enum class RunOneResult : int {
24 NoTasks = 0,
25 TaskExecuted = 1,
26 Retry = 2,
27 };
28
29 enum class State : int {
30 Initializing = 0,
31 Off = 1,
32 Running = 2,
33 };
34
35public:
36 // member variables
37 // NOLINTBEGIN
54 // NOLINTEND
55
56public:
57 // prevent constructor by default
58 BackgroundWorker& operator=(BackgroundWorker const&);
59 BackgroundWorker(BackgroundWorker const&);
60 BackgroundWorker();
61
62public:
63 // virtual functions
64 // NOLINTBEGIN
65 virtual ~BackgroundWorker() /*override*/;
66
67 virtual bool isAsync() const /*override*/;
68
69 virtual bool canTaskRunAgain() const /*override*/;
70 // NOLINTEND
71
72public:
73 // member functions
74 // NOLINTBEGIN
76 ::std::string_view name,
77 ::Core::Profile::ThreadFrameType frameType,
78 bool async,
80 ::std::optional<uint64> coreAffinity,
81 ::std::optional<int> idealCore,
82 ::WorkerPool& workerPool
83 );
84
85 MCNAPI void _doNoWorkDelay();
86
87 MCNAPI bool _processNextTask(::RunTaskOptions const& options);
88
89 MCNAPI ::BackgroundWorker::RunOneResult _runOneTask(::RunTaskOptions const& options);
90
91 MCNAPI ::std::shared_ptr<::BackgroundTaskBase> _tryPop(::WorkerPool& pool);
92
93 MCNAPI uint64 getApproximateTaskCount() const;
94
95 MCNAPI ::RunTaskOptions getRunOptions();
96
97 MCNAPI ::std::thread::id getThreadId() const;
98
99 MCNAPI bool isIdle() const;
100
101 MCNAPI bool processTaskSync(::RunTaskOptions const& options);
102
103 MCNAPI void queue(::std::shared_ptr<::BackgroundTaskBase> task);
104
105 MCNAPI void requestStop(bool wait);
106
107 MCNAPI void resortPriorityQueue();
108
109 MCNAPI void start();
110
111 MCNAPI void wake();
112 // NOLINTEND
113
114public:
115 // static functions
116 // NOLINTBEGIN
117 MCNAPI static ::BackgroundWorker* getLocal();
118 // NOLINTEND
119
120public:
121 // static variables
122 // NOLINTBEGIN
123 MCNAPI static ::BackgroundWorker*& gLocalWorkerMappingSingleton();
124 // NOLINTEND
125
126public:
127 // constructor thunks
128 // NOLINTBEGIN
129 MCNAPI void* $ctor(
130 ::std::string_view name,
131 ::Core::Profile::ThreadFrameType frameType,
132 bool async,
134 ::std::optional<uint64> coreAffinity,
135 ::std::optional<int> idealCore,
136 ::WorkerPool& workerPool
137 );
138 // NOLINTEND
139
140public:
141 // destructor thunk
142 // NOLINTBEGIN
143 MCNAPI void $dtor();
144 // NOLINTEND
145
146public:
147 // virtual function thunks
148 // NOLINTBEGIN
149 MCNAPI bool $isAsync() const;
150
151 MCNAPI bool $canTaskRunAgain() const;
152
153
154 // NOLINTEND
155
156public:
157 // vftables
158 // NOLINTBEGIN
159 MCNAPI static void** $vftable();
160 // NOLINTEND
161};
Definition BackgroundTaskBase.h:16
MCAPI BackgroundWorker(::std::string_view name, ::Core::Profile::ThreadFrameType frameType, bool async, ::Bedrock::Threading::OSThreadPriority const &priority, ::std::optional< uint64 > coreAffinity, ::std::optional< int > idealCore, ::WorkerPool &workerPool)
MCAPI bool $isAsync() const
MCAPI::BackgroundWorker::RunOneResult _runOneTask(::RunTaskOptions const &options)
MCAPI void requestStop(bool wait)
MCAPI bool $canTaskRunAgain() const
static MCAPI ::BackgroundWorker *& gLocalWorkerMappingSingleton()
MCAPI::RunTaskOptions getRunOptions()
MCAPI void start()
MCAPI void queue(::std::shared_ptr<::BackgroundTaskBase > task)
MCAPI void $dtor()
static MCAPI ::BackgroundWorker * getLocal()
MCAPI bool _processNextTask(::RunTaskOptions const &options)
static MCAPI void ** $vftable()
MCAPI void wake()
MCAPI void * $ctor(::std::string_view name, ::Core::Profile::ThreadFrameType frameType, bool async, ::Bedrock::Threading::OSThreadPriority const &priority, ::std::optional< uint64 > coreAffinity, ::std::optional< int > idealCore, ::WorkerPool &workerPool)
MCAPI void _doNoWorkDelay()
MCAPI ::std::shared_ptr<::BackgroundTaskBase > _tryPop(::WorkerPool &pool)
MCAPI uint64 getApproximateTaskCount() const
MCAPI void resortPriorityQueue()
MCAPI bool isIdle() const
MCAPI bool processTaskSync(::RunTaskOptions const &options)
MCAPI::std::thread::id getThreadId() const
Definition OSThreadPriority.h:7
Definition ITaskExecutionContext.h:5
Definition WorkerPool.h:20
Definition RunTaskOptions.h:5
Definition Alias.h:14