// Copyright UnexGames 2025. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "ThreadBase.h" #include "ThreadPool.h" #include "Async/Async.h" #include "ThreadTaskBase.generated.h" UENUM(BlueprintType) enum class ETaskExecutionType : uint8 { /** Execute in separate thread. */ Thread, TaskGraph, ThreadPool, }; UCLASS(NotBlueprintType, NotBlueprintable) class MULTITHREADLIBRARY_API UThreadTaskBase : public UThreadBase { GENERATED_BODY() public: UThreadTaskBase(); ~UThreadTaskBase(); /** * Check whether the work is in progress. */ virtual bool IsRunning() override; private: void OnEndPIE(bool bIsSimulating); void OnPreExit(); public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MultiThreadLibrary") ETaskExecutionType ExecutionType = ETaskExecutionType::Thread; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MultiThreadLibrary") UThreadPool* ThreadPool; protected: TArray> Tasks; private: #if WITH_EDITOR FDelegateHandle EndPIEHandle; #else FDelegateHandle PreExitHandle; #endif };