thread-safe sgbackend initialization
This commit is contained in:
@@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- SenseGlove libraries have migrated to `C++20` from `C++17`.
|
- SenseGlove libraries have migrated to `C++20` from `C++17`.
|
||||||
- Revamped the `SGLog` logging utility class to use `TUniquePtr` instead of `std::unique_ptr`.
|
- Revamped the `SGLog` logging utility class to use `TUniquePtr` instead of `std::unique_ptr`.
|
||||||
- `SGLog` now relies on `TAtomic<bool>` for thread-safe initialization.
|
- `SGLog` now relies on `TAtomic<bool>` for thread-safe initialization.
|
||||||
|
- `SGBackend` now relies on `TAtomic<bool>` for thread-safe initialization.
|
||||||
|
- `USGBackend::IsBackendInitialized()` is no longer inlined and the initialization flag has been moved to the private implementation of `USGBackend`.
|
||||||
- Bumped the SenseGlove Unreal Engine Marketplace Packager `v0.6.0-4108c6f`.
|
- Bumped the SenseGlove Unreal Engine Marketplace Packager `v0.6.0-4108c6f`.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "SGBackend/SGBackend.h"
|
#include "SGBackend/SGBackend.h"
|
||||||
|
|
||||||
#include "Engine/Engine.h"
|
#include "Engine/Engine.h"
|
||||||
|
#include "Templates/Atomic.h"
|
||||||
|
|
||||||
#if PLATFORM_ANDROID
|
#if PLATFORM_ANDROID
|
||||||
#include "SGConnect/SGConnect.h"
|
#include "SGConnect/SGConnect.h"
|
||||||
@@ -47,6 +48,12 @@
|
|||||||
|
|
||||||
struct USGBackend::FImpl
|
struct USGBackend::FImpl
|
||||||
{
|
{
|
||||||
|
/************************
|
||||||
|
* Member variables
|
||||||
|
************************/
|
||||||
|
|
||||||
|
TAtomic<bool> bInitialized;
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
* Owner object
|
* Owner object
|
||||||
************************/
|
************************/
|
||||||
@@ -82,7 +89,11 @@ USGBackend* USGBackend::GetInstance()
|
|||||||
USGBackend::USGBackend()
|
USGBackend::USGBackend()
|
||||||
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
||||||
{
|
{
|
||||||
bBackendInitialized = false;
|
}
|
||||||
|
|
||||||
|
bool USGBackend::IsBackendInitialized() const
|
||||||
|
{
|
||||||
|
return Pimpl->bInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool USGBackend::InitializeBackend()
|
bool USGBackend::InitializeBackend()
|
||||||
@@ -130,7 +141,7 @@ bool USGBackend::InitializeBackend()
|
|||||||
FSGDeviceList::Dispose();
|
FSGDeviceList::Dispose();
|
||||||
FSGDeviceList::Reinitialize();
|
FSGDeviceList::Reinitialize();
|
||||||
|
|
||||||
bBackendInitialized = true;
|
Pimpl->bInitialized = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -181,7 +192,7 @@ bool USGBackend::UninitializeBackend()
|
|||||||
}
|
}
|
||||||
#endif /* PLATFORM_ANDROID */
|
#endif /* PLATFORM_ANDROID */
|
||||||
|
|
||||||
bBackendInitialized = false;
|
Pimpl->bInitialized = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -235,7 +246,8 @@ void USGBackend::Deinitialize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
USGBackend::FImpl::FImpl(USGBackend* InOwner)
|
USGBackend::FImpl::FImpl(USGBackend* InOwner)
|
||||||
: Owner(InOwner)
|
: bInitialized(false),
|
||||||
|
Owner(InOwner)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,10 +49,6 @@ class SENSEGLOVEBACKEND_API USGBackend : public UEngineSubsystem
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
private:
|
|
||||||
UPROPERTY(Transient)
|
|
||||||
bool bBackendInitialized;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static USGBackend* GetInstance();
|
static USGBackend* GetInstance();
|
||||||
|
|
||||||
@@ -71,10 +67,7 @@ private:
|
|||||||
USGBackend();
|
USGBackend();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FORCEINLINE bool IsBackendInitialized() const
|
bool IsBackendInitialized() const;
|
||||||
{
|
|
||||||
return bBackendInitialized;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool InitializeBackend();
|
bool InitializeBackend();
|
||||||
bool UninitializeBackend();
|
bool UninitializeBackend();
|
||||||
|
|||||||
Reference in New Issue
Block a user