From 3853cbe5d205558bfb6d0f5c38df26df4135fe21 Mon Sep 17 00:00:00 2001 From: Jeki <40406669+JekiTheMonkey@users.noreply.github.com> Date: Sat, 13 Jan 2024 14:10:02 +0100 Subject: [PATCH] refactor: make RUN_LATENT_EXECUTION() wrap the co_await --- .../UE5FSM/Public/FiniteStateMachine/MachineState.h | 3 ++- .../Private/MachineState_ExternalPushPopTest.cpp | 2 +- .../UE5FSMTests/Private/MachineState_ExternalPushTest.cpp | 2 +- .../UE5FSMTests/Private/MachineState_LatentTest.cpp | 8 ++++---- .../UE5FSMTests/Private/MachineState_PushPopTest.cpp | 8 ++++---- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Plugins/UE5FSM/Source/UE5FSM/Public/FiniteStateMachine/MachineState.h b/Plugins/UE5FSM/Source/UE5FSM/Public/FiniteStateMachine/MachineState.h index f276cfb..157d2b2 100644 --- a/Plugins/UE5FSM/Source/UE5FSM/Public/FiniteStateMachine/MachineState.h +++ b/Plugins/UE5FSM/Source/UE5FSM/Public/FiniteStateMachine/MachineState.h @@ -72,7 +72,8 @@ UE5FSM_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TAG_StateMachine_Label_Default); #define TO_STR(x) #x #define RUN_LATENT_EXECUTION(FUNCTION, ...) \ - RunLatentExecutionExt(LIFT(FUNCTION), *FString::Printf(TEXT("Caller function [%s] Line [%d] Latent function [%s]"), \ + co_await RunLatentExecutionExt(LIFT(FUNCTION), *FString::Printf( \ + TEXT("Caller function [%s] Line [%d] Latent function [%s]"), \ *FString(__FUNCTION__), __LINE__, *FString(TO_STR(FUNCTION))), ## __VA_ARGS__) /** diff --git a/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_ExternalPushPopTest.cpp b/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_ExternalPushPopTest.cpp index d0d56df..8f16ecc 100644 --- a/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_ExternalPushPopTest.cpp +++ b/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_ExternalPushPopTest.cpp @@ -2,6 +2,6 @@ TCoroutine<> UMachineState_ExternalPushPopTest::Label_Default() { - co_await RUN_LATENT_EXECUTION(Latent::Seconds, 0.5); + RUN_LATENT_EXECUTION(Latent::Seconds, 0.5); BROADCAST_TEST_MESSAGE("Post default label", true); } diff --git a/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_ExternalPushTest.cpp b/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_ExternalPushTest.cpp index 466166e..96ef40b 100644 --- a/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_ExternalPushTest.cpp +++ b/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_ExternalPushTest.cpp @@ -43,6 +43,6 @@ TCoroutine<> UMachineState_ExternalPushTest::Label_Default() while (true) { BROADCAST_TEST_MESSAGE("Hello", true); - co_await RUN_LATENT_EXECUTION(Latent::Seconds, 0.4f); + RUN_LATENT_EXECUTION(Latent::Seconds, 0.4f); } } diff --git a/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_LatentTest.cpp b/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_LatentTest.cpp index 58a9398..45d5754 100644 --- a/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_LatentTest.cpp +++ b/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_LatentTest.cpp @@ -9,7 +9,7 @@ TCoroutine<> UMachineState_GotoStateTest1::Label_Default() BROADCAST_TEST_MESSAGE("Goto test 2 fail", true); // Wait one tick to due to the reason described above - co_await RUN_LATENT_EXECUTION(Latent::NextTick); + RUN_LATENT_EXECUTION(Latent::NextTick); BROADCAST_TEST_MESSAGE("Pre goto test 2", true); GOTO_STATE(UMachineState_GotoStateTest2); @@ -21,7 +21,7 @@ TCoroutine<> UMachineState_GotoStateTest1::Label_Default() TCoroutine<> UMachineState_GotoStateTest2::Label_Default() { - co_await RUN_LATENT_EXECUTION(Latent::Seconds, 1.0); + RUN_LATENT_EXECUTION(Latent::Seconds, 1.0); BROADCAST_TEST_MESSAGE("End test", true); co_return; } @@ -32,7 +32,7 @@ TCoroutine<> UMachineState_LatentExecutionTest1::Label_Default() GetTimerManager().SetTimer(TimerHandle, this, &ThisClass::PushLatentExecutionTest2, 1.f, false); BROADCAST_TEST_MESSAGE("Pre sleep", true); - co_await RUN_LATENT_EXECUTION(Latent::Seconds, 2.0); + RUN_LATENT_EXECUTION(Latent::Seconds, 2.0); BROADCAST_TEST_MESSAGE("Post sleep", true); BROADCAST_TEST_MESSAGE("End test", true); } @@ -47,7 +47,7 @@ void UMachineState_LatentExecutionTest1::PushLatentExecutionTest2() TCoroutine<> UMachineState_LatentExecutionTest2::Label_Default() { BROADCAST_TEST_MESSAGE("Pre sleep", true); - co_await RUN_LATENT_EXECUTION(Latent::Seconds, 3.5); + RUN_LATENT_EXECUTION(Latent::Seconds, 3.5); BROADCAST_TEST_MESSAGE("Post sleep", true); BROADCAST_TEST_MESSAGE("Pre pop", true); POP_STATE(); diff --git a/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_PushPopTest.cpp b/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_PushPopTest.cpp index 2df0c7b..7ca4100 100644 --- a/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_PushPopTest.cpp +++ b/Plugins/UE5FSM/Source/UE5FSMTests/Private/MachineState_PushPopTest.cpp @@ -32,7 +32,7 @@ TCoroutine<> UMachineState_PushPopTest::Label_Default() BROADCAST_TEST_MESSAGE("Before test label activation", true); // Should be cancelled by the test label - co_await RUN_LATENT_EXECUTION(Latent::Seconds, 120.0); + RUN_LATENT_EXECUTION(Latent::Seconds, 120.0); BROADCAST_TEST_MESSAGE("Latent execution has been cancelled", true); } } @@ -46,10 +46,10 @@ TCoroutine<> UMachineState_PushPopTest::Label_Test() if (IsValid(LatentPushState)) { - co_await RUN_LATENT_EXECUTION(Latent::Seconds, 1.0); - co_await PUSH_STATE_CLASS(LatentPushState); + RUN_LATENT_EXECUTION(Latent::Seconds, 1.0); + PUSH_STATE_CLASS(LatentPushState); } - co_await RUN_LATENT_EXECUTION(Latent::Seconds, 1.0); + RUN_LATENT_EXECUTION(Latent::Seconds, 1.0); POP_STATE(); }