Navigation
API > API/Runtime > API/Runtime/Core
RAII-style scope locking of a synchronization primitive using TryLock. MutexType_ must be a type like UE::FMutex or FCriticalSection_ which implements TryLock and `Unlock_ methods.
` { // Try to acquire a lock on Mutex for the current scope. UE::TScopeTryLock ScopeTryLock(Mutex);_
` // Check that the lock was acquired. if (ScopeTryLock.IsLocked()) { // If the lock was acquired, we can safely access resources protected // by the mutex. }_
` // When ScopeTryLock goes out of scope, the mutex will be released if it was // ever acquired. } _
| Name | TScopeTryLock |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Misc/ScopeTryLock.h |
| Include Path | #include "Misc/ScopeTryLock.h" |
Syntax
template<typename MutexType>
class TScopeTryLock
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TScopeTryLock
(
MutexType& InMutex |
Misc/ScopeTryLock.h | ||
TScopeTryLock
(
const TScopeTryLock& |
Misc/ScopeTryLock.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~TScopeTryLock() |
Misc/ScopeTryLock.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| HeldMutex | MutexType * | Misc/ScopeTryLock.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool IsLocked() |
Misc/ScopeTryLock.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TScopeTryLock & operator=
(
TScopeTryLock& |
Misc/ScopeTryLock.h |