Skip to content

Instantly share code, notes, and snippets.

@Pranavpaharia
Created Jan 13, 2020
Embed
What would you like to do?
FRunnableThread Header File
// Copyright Thoughtfish GmbH, 2019
// http://www.thoughtfish.de
#pragma once
#include "CoreMinimal.h"
/**
*
*/
#include "Core/Public/Async/Async.h"
DECLARE_DELEGATE(FJsonRead);
class THOUGHTFISHCOALAPLUGIN_API FCoalaReadJsonAsync : public FRunnable
{
public:
static FCoalaReadJsonAsync* Runnable;
FRunnableThread* Thread;
class UCoalaArea* result;
FString Raw;
int _defaultBuildingLevel;
bool _clampToDefaultBuildingLevel;
int _limitMaxBuildingLevelTo;
FThreadSafeCounter StopTaskCounter;
static bool isDone;
void JsonToCoalaArea(FString JsonRaw, int defaultBuildingLevel, bool clampToDefaultBuildingLevel, int limitMaxBuildingLevelTo, UCoalaArea* result);
FCoalaReadJsonAsync(FString JsonRaw, int defaultBuildingLevel, bool clampToDefaultBuildingLevel, int limitMaxBuildingLevelTo, UCoalaArea* initializedObject);
virtual ~FCoalaReadJsonAsync();
// Begin FRunnable interface.
virtual bool Init();
virtual uint32 Run();
//virtual void Stop();
// End FRunnable interface
/** Makes sure this thread has stopped properly */
void EnsureCompletion();
static UCoalaArea* GetResult();
static FCoalaReadJsonAsync* JoyInit(FString JsonRaw, int defaultBuildingLevel, bool clampToDefaultBuildingLevel, int limitMaxBuildingLevelTo, UCoalaArea* initializedObject);
/** Shuts down the thread. Static so it can easily be called from outside the thread context */
static void Shutdown();
static bool IsThreadFinished();
static void JsonToCoalaArea(FString jsonString, int defaultBuildingLevel, bool clampToDefaultBuildingLevel, int limitMaxBuildingLevelTo, bool async, UCoalaArea* ret);
FJsonRead JsonRead;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment