87 lines
1.3 KiB
C++
87 lines
1.3 KiB
C++
// Copyright UnexGames 2025. All Rights Reserved.
|
|
#include "ThreadBase.h"
|
|
#include "Async/Async.h"
|
|
#ifndef ENGINE_MINOR_VERSION
|
|
#include "Runtime/Launch/Resources/Version.h"
|
|
#endif
|
|
|
|
|
|
UThreadBase::UThreadBase()
|
|
{
|
|
|
|
}
|
|
|
|
UThreadBase::~UThreadBase()
|
|
{
|
|
}
|
|
|
|
bool UThreadBase::Start()
|
|
{
|
|
|
|
unimplemented();
|
|
return false;
|
|
}
|
|
|
|
void UThreadBase::Cancel()
|
|
{
|
|
if (IsRunning() && !IsCanceled())
|
|
{
|
|
bCanceled = true;
|
|
UThreadBase* Worker = this;
|
|
if (Worker != nullptr && Worker->IsValidLowLevel() && IsValid(Worker) && !Worker->IsUnreachable())
|
|
{
|
|
Worker->OnCancel();
|
|
if (Worker->OnCancelDelegate.IsBound())
|
|
{
|
|
Worker->OnCancelDelegate.Broadcast();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void UThreadBase::WaitToFinish()
|
|
{
|
|
while (IsRunning());
|
|
}
|
|
|
|
|
|
bool UThreadBase::IsRunning()
|
|
{
|
|
unimplemented();
|
|
return false;
|
|
}
|
|
|
|
bool UThreadBase::IsCanceled()
|
|
{
|
|
return bCanceled;
|
|
}
|
|
|
|
void UThreadBase::OnCancel_Implementation()
|
|
{
|
|
this->BeginDestroy();
|
|
}
|
|
|
|
void UThreadBase::OnComplete_Implementation()
|
|
{
|
|
}
|
|
|
|
|
|
UWorld* UThreadBase::GetWorld() const
|
|
{
|
|
if (HasAllFlags(RF_ClassDefaultObject))
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
if (IsValid(GetOuter()))
|
|
{
|
|
return GetOuter()->GetWorld();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
|
|
|
|
|