Skip to content

Commit

Permalink
Unreal upgrade fixes (#40)
Browse files Browse the repository at this point in the history
* Pushing a number of engine upgrade fixes upstream

* Added some additional test changes
  • Loading branch information
digibob committed Jul 18, 2024
1 parent 07e089e commit 4ccfc20
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ SD::TExpectedFuture<void> SD::WaitAsync(const float DelayInSeconds)
{
const TSharedRef<TExpectedPromise<void>> Promise = MakeShared<TExpectedPromise<void>>();

FTicker::GetCoreTicker().AddTicker(
FTSTicker::GetCoreTicker().AddTicker(
FTickerDelegate::CreateLambda([Promise](const float Delta)
{
Promise->SetValue();
Expand Down
6 changes: 3 additions & 3 deletions Source/SDFutureExtensions/Public/ExpectedFuture.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#pragma once

#include "Async/Future.h"
#include "SDFutureExtensions/Private/FutureExtensionsTypeTraits.h"
#include "FutureExtensionsTypeTraits.h"
#include "Templates/AreTypesEqual.h"
#include "Async/TaskGraphInterfaces.h"
#include "Misc/QueuedThreadPool.h"
Expand Down Expand Up @@ -648,15 +648,15 @@ namespace SD
return ValuePromise.GetFuture();
}

template <typename T, typename R, typename TEnableIf<TIsSame<T, R>::Value>::Type* = nullptr>
template <typename T, typename R, typename TEnableIf<std::is_same_v<T, R>>::Type* = nullptr>
TExpectedFuture<T> MakeReadyFutureFromExpected(const TExpected<R>& InExpected)
{
TExpectedPromise<T> Promise = TExpectedPromise<T>();
Promise.SetValue(InExpected);
return Promise.GetFuture();
}

template <typename T, typename R, typename TEnableIf<!TIsSame<T, R>::Value>::Type* = nullptr>
template <typename T, typename R, typename TEnableIf<!std::is_same_v<T, R>>::Type* = nullptr>
TExpectedFuture<T> MakeReadyFutureFromExpected(const TExpected<R>& InExpected)
{
return MakeReadyFuture<T>(Convert<T>(InExpected));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "Async/Async.h"
#include "CancellationHandle.h"
#include <type_traits>

//TODO: can be rewriten with C++17 `if constexpr`

Expand Down Expand Up @@ -319,7 +320,7 @@ namespace SD
class TExpectedFutureInitTask : public FAsyncGraphTaskBase
{
using SharedPromiseRef = TSharedRef<TExpectedPromise<R>, ESPMode::ThreadSafe>;
using FFunctorType = typename TRemoveCV<typename TRemoveReference<F>::Type>::Type;
using FFunctorType = TRemoveCVRef<F>;

public:
TExpectedFutureInitTask(F&& InFunc, const SharedPromiseRef& InPromise,
Expand Down Expand Up @@ -354,7 +355,7 @@ namespace SD
class TExpectedFutureContinuationTask : public FAsyncGraphTaskBase
{
using SharedPromiseRef = TSharedRef<TExpectedPromise<R>, ESPMode::ThreadSafe>;
using FFunctorType = typename TRemoveCV<typename TRemoveReference<F>::Type>::Type;
using FFunctorType = TRemoveCVRef<F>;

public:
TExpectedFutureContinuationTask(F&& InFunction, const SharedPromiseRef& InPromise,
Expand Down Expand Up @@ -460,7 +461,7 @@ namespace SD
class TExpectedFutureInitQueuedWork : public TExpectedFutureQueuedWork<R>
{
using SharedPromiseRef = TSharedRef<TExpectedPromise<R>, ESPMode::ThreadSafe>;
using FFunctorType = typename TRemoveCV<typename TRemoveReference<F>::Type>::Type;
using FFunctorType = TRemoveCVRef<F>;

public:
TExpectedFutureInitQueuedWork(F&& InFunc, const SharedPromiseRef& InPromise,
Expand Down Expand Up @@ -492,7 +493,7 @@ namespace SD
class TExpectedFutureContinuationQueuedWork : public TExpectedFutureQueuedWork<R>
{
using SharedPromiseRef = TSharedRef<TExpectedPromise<R>, ESPMode::ThreadSafe>;
using FFunctorType = typename TRemoveCV<typename TRemoveReference<F>::Type>::Type;
using FFunctorType = TRemoveCVRef<F>;

public:
TExpectedFutureContinuationQueuedWork(F&& InFunction, const SharedPromiseRef& InPromise,
Expand Down
2 changes: 1 addition & 1 deletion Source/SDFutureExtensions/Public/FutureExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
#include "ExpectedResult.h"
#include "ExpectedFutureOptions.h"
#include "ExpectedFuture.h"
#include "SDFutureExtensions/Private/FutureExtensionTaskGraph.h"
#include "FutureExtensionTaskGraph.h"
#include "FutureExtensionsStaticFuncs.h"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "ExpectedResult.h"
#include "ExpectedFuture.h"
#include "SDFutureExtensions/Private/FutureExtensionTaskGraph.h"
#include "FutureExtensionTaskGraph.h"

namespace SD
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ namespace SD

namespace FutureExtensionTypeTraits
{
/**
* Cannot use std::remove_cvref_t as this is not available in all SDKs
*/
template <class T>
using TRemoveCVRef = std::remove_cv_t<std::remove_reference_t<T>>;

/*
* Helper type traits for determining if types are either Expected or ExpectedFuture.
* Required as certain functionality (such as implicit unwrapping of futures/types) requires
Expand Down Expand Up @@ -87,17 +93,17 @@ namespace SD

using IsPlainValueOrExpected = TIntegralConstant<bool, !IsExpectedFuture::value &&
(TIsExpected<ReturnType>::value ||
!TIsVoidType<ReturnType>::Value)>;
!std::is_void<ReturnType>::value)>;

using IsNonExpectedAndVoid = TIntegralConstant<bool, !TIsExpected<ReturnType>::value &&
TIsVoidType<ReturnType>::Value>;
std::is_void<ReturnType>::value>;
};

template<typename ParamType>
struct TParamTypeSpecializations
{
using IsVoidValueBased = TIsVoidType<ParamType>;
using IsNonVoidValueBased = TIntegralConstant<bool, !TIsVoidType<ParamType>::Value &&
using IsVoidValueBased = std::is_void<ParamType>;
using IsNonVoidValueBased = TIntegralConstant<bool, !std::is_void<ParamType>::value &&
!TIsExpected<ParamType>::value>;
using IsExpectedBased = TIsExpected<ParamType>;
};
Expand Down Expand Up @@ -172,7 +178,7 @@ namespace SD
struct TContinuationFunctorReturnType {};

template<typename F, typename P>
struct TContinuationFunctorReturnType<F, P, typename TEnableIf<!TIsVoidType<P>::Value>::Type>
struct TContinuationFunctorReturnType<F, P, typename TEnableIf<!std::is_void<P>::value>::Type>
{
#if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 26 && ENGINE_PATCH_VERSION >= 1
using ReturnType = typename TInvokeResult<typename std::decay_t<F>, P>::Type;
Expand All @@ -184,7 +190,7 @@ namespace SD
};

template<typename F, typename P>
struct TContinuationFunctorReturnType<F, P, typename TEnableIf<TIsVoidType<P>::Value>::Type>
struct TContinuationFunctorReturnType<F, P, typename TEnableIf<std::is_void<P>::value>::Type>
{
#if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 26 && ENGINE_PATCH_VERSION >= 1
using ReturnType = typename TInvokeResult<typename std::decay_t<F>>::Type;
Expand All @@ -205,7 +211,7 @@ namespace SD

using IsReturnsVoidAndTakesVoid =
TIntegralConstant<bool, ReturnSpec::IsNonExpectedAndVoid::Value &&
ParamSpec::IsVoidValueBased::Value>;
ParamSpec::IsVoidValueBased::value>;

using IsReturnsVoidAndTakesValue =
TIntegralConstant<bool, ReturnSpec::IsNonExpectedAndVoid::Value &&
Expand All @@ -217,7 +223,7 @@ namespace SD

using IsReturnsExpectedFutureAndTakesVoid =
TIntegralConstant<bool, ReturnSpec::IsExpectedFuture::value &&
ParamSpec::IsVoidValueBased::Value>;
ParamSpec::IsVoidValueBased::value>;

using IsReturnsExpectedFutureAndTakesValue =
TIntegralConstant<bool, ReturnSpec::IsExpectedFuture::value &&
Expand All @@ -229,7 +235,7 @@ namespace SD

using IsReturnsPlainValueOrExpectedAndTakesVoid =
TIntegralConstant<bool, ReturnSpec::IsPlainValueOrExpected::Value &&
ParamSpec::IsVoidValueBased::Value>;
ParamSpec::IsVoidValueBased::value>;

using IsReturnsPlainValueOrExpectedAndTakesValue =
TIntegralConstant<bool, ReturnSpec::IsPlainValueOrExpected::Value &&
Expand Down
2 changes: 1 addition & 1 deletion Source/Test/Private/BasicFutures.spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void FFutureTestSpec_Basic::Define()
{
return 10;
})
.Then([](SD::TExpected<int32> Expected)
.Then([](SD::TExpected<int32> Expected) -> SD::TExpected<int32>
{
//Pass initial result straight through
return Expected;
Expand Down
2 changes: 1 addition & 1 deletion Source/Test/Private/Cancellation.spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void FFutureTestSpec_Cancellation::Define()
{
return Expected;
}, SD::FExpectedFutureOptions(CancellationHandle))
.Then([](SD::TExpected<int32> Expected)
.Then([](SD::TExpected<int32> Expected) -> SD::TExpected<bool>
{
//Then expected-based continuation is called with "Cancelled" status
return SD::MakeReadyExpected<bool>(Expected.IsCancelled());
Expand Down
3 changes: 1 addition & 2 deletions Source/Test/Private/CombinedFutures.spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "Helpers/TestHelpers.h"


#if WITH_DEV_AUTOMATION_TESTS

/************************************************************************/
Expand All @@ -14,7 +13,7 @@

class FFutureTestSpec_Combined : public FFutureTestSpec
{
GENERATE_SPEC(FFutureTestSpec_Basic, "FutureExtensions.Combined",
GENERATE_SPEC(FFutureTestSpec_Combined, "FutureExtensions.Combined",
EAutomationTestFlags::ProductFilter |
EAutomationTestFlags::EditorContext |
EAutomationTestFlags::ServerContext
Expand Down
4 changes: 2 additions & 2 deletions Source/Test/Private/ExecutionPolicy.spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void FFutureTestSpec_ExecutionPolicy::Define()
.SetExecutionPolicy(SD::EExpectedFutureExecutionPolicy::NamedThread)
.SetDesiredExecutionThread(ENamedThreads::GameThread)
.Build())
.Then([](SD::TExpected<void> Expected)
.Then([](SD::TExpected<void> Expected) -> SD::TExpected<ENamedThreads::Type>
{
return SD::MakeReadyExpected(FTaskGraphInterface::Get().GetCurrentThreadIfKnown());
}, SD::FExpectedFutureOptionsBuilder()
Expand Down Expand Up @@ -127,7 +127,7 @@ void FFutureTestSpec_ExecutionPolicy::Define()
{
return SD::MakeReadyExpected();
})
.Then([](SD::TExpected<void> Expected)
.Then([](SD::TExpected<void> Expected) -> SD::TExpected<ENamedThreads::Type>
{
return SD::MakeReadyExpected(FTaskGraphInterface::Get().GetCurrentThreadIfKnown());
}, SD::FExpectedFutureOptionsBuilder()
Expand Down

0 comments on commit 4ccfc20

Please sign in to comment.