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`.
|
||||
- Revamped the `SGLog` logging utility class to use `TUniquePtr` instead of `std::unique_ptr`.
|
||||
- `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`.
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "SGBackend/SGBackend.h"
|
||||
|
||||
#include "Engine/Engine.h"
|
||||
#include "Templates/Atomic.h"
|
||||
|
||||
#if PLATFORM_ANDROID
|
||||
#include "SGConnect/SGConnect.h"
|
||||
@@ -47,6 +48,12 @@
|
||||
|
||||
struct USGBackend::FImpl
|
||||
{
|
||||
/************************
|
||||
* Member variables
|
||||
************************/
|
||||
|
||||
TAtomic<bool> bInitialized;
|
||||
|
||||
/************************
|
||||
* Owner object
|
||||
************************/
|
||||
@@ -82,7 +89,11 @@ USGBackend* USGBackend::GetInstance()
|
||||
USGBackend::USGBackend()
|
||||
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
||||
{
|
||||
bBackendInitialized = false;
|
||||
}
|
||||
|
||||
bool USGBackend::IsBackendInitialized() const
|
||||
{
|
||||
return Pimpl->bInitialized;
|
||||
}
|
||||
|
||||
bool USGBackend::InitializeBackend()
|
||||
@@ -130,7 +141,7 @@ bool USGBackend::InitializeBackend()
|
||||
FSGDeviceList::Dispose();
|
||||
FSGDeviceList::Reinitialize();
|
||||
|
||||
bBackendInitialized = true;
|
||||
Pimpl->bInitialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -181,7 +192,7 @@ bool USGBackend::UninitializeBackend()
|
||||
}
|
||||
#endif /* PLATFORM_ANDROID */
|
||||
|
||||
bBackendInitialized = false;
|
||||
Pimpl->bInitialized = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -235,7 +246,8 @@ void USGBackend::Deinitialize()
|
||||
}
|
||||
|
||||
USGBackend::FImpl::FImpl(USGBackend* InOwner)
|
||||
: Owner(InOwner)
|
||||
: bInitialized(false),
|
||||
Owner(InOwner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,6 @@ class SENSEGLOVEBACKEND_API USGBackend : public UEngineSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
UPROPERTY(Transient)
|
||||
bool bBackendInitialized;
|
||||
|
||||
public:
|
||||
static USGBackend* GetInstance();
|
||||
|
||||
@@ -71,10 +67,7 @@ private:
|
||||
USGBackend();
|
||||
|
||||
public:
|
||||
FORCEINLINE bool IsBackendInitialized() const
|
||||
{
|
||||
return bBackendInitialized;
|
||||
}
|
||||
bool IsBackendInitialized() const;
|
||||
|
||||
bool InitializeBackend();
|
||||
bool UninitializeBackend();
|
||||
|
||||
Reference in New Issue
Block a user