Created
July 24, 2019 16:43
-
-
Save hxhb/374b33fd6fcbe38868f095f4c787755e to your computer and use it in GitHub Desktop.
UE4 FRunnable Wrapper class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "HAL/Runnable.h" | |
#include "HAL/RunnableThread.h" | |
class FThread : public FRunnable | |
{ | |
public: | |
using FCallback = TFunction<void()>; | |
explicit FThread(const TCHAR *pThreadName, const FCallback& pCallback) | |
:mCallback(pCallback) | |
{ | |
mThread = FRunnableThread::Create(this,pThreadName); | |
} | |
void Join() | |
{ | |
mThread->WaitForCompletion(); | |
} | |
virtual uint32 Run()override | |
{ | |
mCallback(); | |
return 0; | |
} | |
virtual void Exit()override | |
{ | |
} | |
private: | |
FCallback mCallback; | |
FRunnableThread* mThread; | |
private: | |
FThread(const FThread&) = delete; | |
FThread& operator=(const FThread&) =delete; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment