October3d55/M/MultiThread/Source/MultiThreadLibrary/Public/ThreadPool.h

41 lines
942 B
C++

// Copyright UnexGames 2025. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Misc/QueuedThreadPool.h"
#include "UObject/Object.h"
#include "Templates/SharedPointer.h"
#ifndef ENGINE_MINOR_VERSION
#include "Runtime/Launch/Resources/Version.h"
#endif
#include "ThreadPool.generated.h"
UENUM(BlueprintType)
enum class EThreadPoolPriority : uint8
{
Normal,
AboveNormal,
BelowNormal,
Highest,
Lowest,
SlightlyBelowNormal,
TimeCritical,
};
UCLASS(BlueprintType, hidecategories = (Object), meta = (DontUseGenericSpawnObject = "true"))
class MULTITHREADLIBRARY_API UThreadPool : public UObject
{
GENERATED_BODY()
public:
bool Create(uint32 InNumQueuedThreads, const FString Name = "CustomThreadPool", EThreadPriority ThreadPriority = TPri_Normal, uint32 StackSize = (32 * 1024));
UFUNCTION(BlueprintPure, Category = "MultiThreadLibrary")
int32 GetThreadsNum();
public:
TSharedPtr <FQueuedThreadPool> Obj;
};