27 MCRO_API
bool IsInThread(ENamedThreads::Type threadName);
33 template <CFunctionLike When>
34 requires (TFunction_ArgCount<When> == 0)
36 ENamedThreads::Type threadName,
37 TUniqueFunction<
void()>&& func, When&& when
40 else AsyncTask(threadName, [when = MoveTemp(when), func = MoveTemp(func)]
42 if (
auto keep = when()) func();
46 template <CFunctionLike When>
47 requires (TFunction_ArgCount<When> == 0)
50 if (IsInRenderingThread()) func(GetImmediateCommandList_ForRenderCommand());
53 ENQUEUE_RENDER_COMMAND(FMcroThreading)([when = MoveTemp(when), func = MoveTemp(func)](FRHICommandListImmediate& cmdList)
55 if (
auto keep = when()) func(cmdList);
60 template <CFunctorObject Function,
typename Result = TFunction_Return<Function>, CFunctionLike When>
62 TFunction_ArgCount<Function> == 0
63 && TFunction_ArgCount<When> == 0
66 ENamedThreads::Type threadName,
71 return MakeFulfilledPromise<Result>(func()).GetFuture();
73 TPromise<Result> promise;
74 auto future = promise.GetFuture();
76 AsyncTask(threadName, [when = MoveTemp(when), func = MoveTemp(func), promise = MoveTemp(promise)]()
mutable
78 if (
auto keep = when()) promise.SetValue(func());
79 else promise.SetValue({});
84 template <CFunctorObject Function,
typename Result = TFunction_Return<Function>, CFunctionLike When>
86 TFunction_ArgCount<Function> == 1
87 && CSameAs<FRHICommandListImmediate&, TFunction_Arg<Function, 0>>
88 && TFunction_ArgCount<When> == 0
91 ENamedThreads::Type threadName,
95 if (IsInRenderingThread())
96 return MakeFulfilledPromise<Result>(func(GetImmediateCommandList_ForRenderCommand())).GetFuture();
98 TPromise<Result> promise;
99 auto future = promise.GetFuture();
101 ENQUEUE_RENDER_COMMAND(FMcroThreading)([when = MoveTemp(when), func = MoveTemp(func), promise = MoveTemp(promise)](FRHICommandListImmediate& cmdList)
mutable
103 if (
auto keep = when())
104 promise.SetValue(func(cmdList));
105 else promise.SetValue({});
112 MCRO_API
void RunInThread(ENamedThreads::Type threadName, TUniqueFunction<
void()>&& func);
118 MCRO_API
void RunInThread(ENamedThreads::Type threadName,
const UObject* boundToObject, TUniqueFunction<
void()>&& func);
124 MCRO_API
void RunInThread(ENamedThreads::Type threadName,
const FWeakObjectPtr& boundToObject, TUniqueFunction<
void()>&& func);
133 MCRO_API
void RunInGameThread(
const UObject* boundToObject, TUniqueFunction<
void()>&& func);
139 MCRO_API
void RunInGameThread(
const FWeakObjectPtr& boundToObject, TUniqueFunction<
void()>&& func);
148 MCRO_API
void EnqueueRenderCommand(
const UObject* boundToObject, TUniqueFunction<
void(FRHICommandListImmediate&)>&& func);
154 MCRO_API
void EnqueueRenderCommand(
const FWeakObjectPtr& boundToObject, TUniqueFunction<
void(FRHICommandListImmediate&)>&& func);
160 template <CSharedOrWeak Object>
161 void RunInThread(ENamedThreads::Type threadName,
const Object& boundToObject, TUniqueFunction<
void()>&& func)
166 return weakObject.Pin();
174 template <CSharedOrWeak Object>
184 template <CSharedOrWeak Object>
185 void EnqueueRenderCommand(
const Object& boundToObject, TUniqueFunction<
void(FRHICommandListImmediate&)>&& func)
190 return weakObject.Pin();
199 CFunctorObject Function,
213 CSharedOrWeak Object,
214 CFunctorObject Function,
218 TFuture<Result>
PromiseInThread(ENamedThreads::Type threadName,
const Object& boundToObject, Function&& func)
223 return weakObject.Pin();
233 CFunctorObject Function,
237 TFuture<Result>
PromiseInThread(ENamedThreads::Type threadName,
const Object* boundToObject, Function&& func)
241 return IsValid(boundToObject) ? TStrongObjectPtr(boundToObject) :
nullptr;
250 CFunctorObject Function,
264 CSharedOrWeak Object,
265 CFunctorObject Function,
274 return weakObject.Pin();
284 CFunctorObject Function,
292 return IsValid(boundToObject) ? TStrongObjectPtr(boundToObject) :
nullptr;
301 CFunctorObject Function,
306 && CSameAs<FRHICommandListImmediate&, TFunction_Arg<Function, 0>>
318 CSharedOrWeak Object,
319 CFunctorObject Function,
324 && CSameAs<FRHICommandListImmediate&, TFunction_Arg<Function, 0>>
331 return weakObject.Pin();
341 CFunctorObject Function,
346 && CSameAs<FRHICommandListImmediate&, TFunction_Arg<Function, 0>>
352 return IsValid(boundToObject) ? TStrongObjectPtr(boundToObject) :
nullptr;