Refactor all thread stuff into its own file

This commit is contained in:
2023-09-04 23:19:10 -04:00
parent 01c37cf2c9
commit cfc536011e
4 changed files with 190 additions and 55 deletions

View File

@@ -8,8 +8,10 @@
#include "DebugPrint.h"
#include "TangibleManager.h"
#include "LuprexSockets.h"
#include "TriggeredTask.h"
#include "IntegrationGameModeBase.generated.h"
/**
*
*/
@@ -29,9 +31,6 @@ public:
// includes: the Luprex engine, the thread, and the socket state.
void ResetToInitialState();
// Method of FRunnable, called by the Luprex thread.
virtual uint32 Run() override;
// Set the entire contents of the console output box.
UFUNCTION(BlueprintImplementableEvent)
void ConsoleSetOutput(const FString& text);
@@ -47,28 +46,23 @@ public:
// Transfer console output from the Luprex engine to unreal.
void HandleLuprexConsoleOutput(FLockedWrapper &w);
// The run function is called by a background thread
// to update luprex sockets and update luprex itself.
virtual uint32 Run() override;
UPROPERTY()
FTangibleManager TangibleManager;
// This stores the entire text currently visible in the console.
FConsoleOutput ConsoleOutput;
// The worker thread.
FRunnableThread *Thread;
// Used to tell the worker thread to stop.
bool ThreadStopRequested;
// This event is used to wake up the Luprex thread. Normally,
// this means we want the worker to do one processing step. But
// if ThreadStopRequested is true, it means we want the thread
// to exit.
FEvent* ThreadEvent;
// The Luprex EngineWrapper, with a Mutex to protect it.
// To access it, construct a FLockedWrapper.
FLockableWrapper LockableWrapper;
// This utility runs the luprex update and socket update in a thread.
FTriggeredTask LuprexUpdateTask;
// Luprex socket system. Aside from construction, only touched by Luprex thread.
TUniquePtr<FLpxSockets> Sockets;