Added blank worker thread
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "IntegrationGameModeBase.h"
|
||||
#include "drvutil.hpp"
|
||||
#include "engineutil.hpp"
|
||||
#include "WorkerRunnable.hpp"
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
@@ -21,7 +22,10 @@ EngineWrapper AIntegrationGameModeBase::Luprex;
|
||||
// engw.play_invoke_event_update(&engw, drvutil::get_monotonic_clock());
|
||||
//}
|
||||
|
||||
AIntegrationGameModeBase::AIntegrationGameModeBase() {
|
||||
AIntegrationGameModeBase::AIntegrationGameModeBase()
|
||||
{
|
||||
Worker = nullptr;
|
||||
Thread = nullptr;
|
||||
//PrimaryActorTick.bCanEverTick = true; // Probably wrong
|
||||
//PrimaryActorTick.bTickEvenWhenPaused = true; // Probably wrong
|
||||
//PrimaryActorTick.TickGroup = TG_PrePhysics; // Probably wrong
|
||||
@@ -29,7 +33,8 @@ AIntegrationGameModeBase::AIntegrationGameModeBase() {
|
||||
SetActorTickInterval(1.0f); // Probably wrong
|
||||
}
|
||||
|
||||
void AIntegrationGameModeBase::HandleConsoleOutput() {
|
||||
void AIntegrationGameModeBase::HandleConsoleOutput()
|
||||
{
|
||||
uint32_t ndata; const char* data;
|
||||
Luprex.get_outgoing(&Luprex, 0, &ndata, &data);
|
||||
if (ndata == 0) return;
|
||||
@@ -41,7 +46,19 @@ void AIntegrationGameModeBase::HandleConsoleOutput() {
|
||||
ConsoleOutput.Append(fs);
|
||||
}
|
||||
|
||||
void AIntegrationGameModeBase::Tick(float DeltaSeconds) {
|
||||
void AIntegrationGameModeBase::WaitForWorkerThread()
|
||||
{
|
||||
if (Thread == nullptr) return;
|
||||
//Worker->Stop();
|
||||
//Thread->WaitForCompletion();
|
||||
delete Thread;
|
||||
delete Worker;
|
||||
Worker = nullptr;
|
||||
Thread = nullptr;
|
||||
}
|
||||
|
||||
void AIntegrationGameModeBase::Tick(float DeltaSeconds)
|
||||
{
|
||||
Super::Tick(DeltaSeconds);
|
||||
if (!luprex_initialized()) {
|
||||
return;
|
||||
@@ -61,7 +78,8 @@ void AIntegrationGameModeBase::Tick(float DeltaSeconds) {
|
||||
}
|
||||
}
|
||||
|
||||
void AIntegrationGameModeBase::ConsoleSendInput(const FString& fs) {
|
||||
void AIntegrationGameModeBase::ConsoleSendInput(const FString& fs)
|
||||
{
|
||||
if (Luprex.engine) {
|
||||
const TCHAR* fstchar = *fs;
|
||||
if (sizeof(TCHAR) == 2) {
|
||||
@@ -74,7 +92,9 @@ void AIntegrationGameModeBase::ConsoleSendInput(const FString& fs) {
|
||||
}
|
||||
}
|
||||
|
||||
void AIntegrationGameModeBase::BeginPlay() {
|
||||
void AIntegrationGameModeBase::BeginPlay()
|
||||
{
|
||||
engineutil::RawPrint("In BeginPlay");
|
||||
Super::BeginPlay();
|
||||
if (!luprex_initialized()) {
|
||||
engineutil::init_wrapper(&Luprex);
|
||||
@@ -102,5 +122,16 @@ void AIntegrationGameModeBase::BeginPlay() {
|
||||
ConsoleOutput.AppendLine(FString("Initialize Luprex Success"));
|
||||
}
|
||||
EngineSeconds = 0;
|
||||
|
||||
if (Thread == nullptr) {
|
||||
Worker = new FWorkerRunnable();
|
||||
Thread = FRunnableThread::Create(Worker, TEXT("Worker Thread"));
|
||||
}
|
||||
}
|
||||
|
||||
void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason) {
|
||||
engineutil::RawPrint("In EndPlay");
|
||||
WaitForWorkerThread();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user