FScopeTryLock

Implements a scope lock using TryLock.

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Misc/ScopeTryLock.h

Include

#include "Misc/ScopeTryLock.h"

Syntax

class FScopeTryLock

Remarks

Implements a scope lock using TryLock.

This is a utility class that handles scope level locking using TryLock. Scope locking helps to avoid programming errors by which a lock is acquired and never released.

` { Try to acquire a lock on CriticalSection for the current scope. FScopeTryLock ScopeTryLock(CriticalSection); Check that the lock was acquired. if (ScopeTryLock.IsLocked()) { If the lock was acquired, we can safely access resources protected by the lock. } When ScopeTryLock goes out of scope, the critical section will be released if it was ever acquired. } _

Constructors

Name Description

Public function

FScopeTryLock

(
    FCriticalSection* InCriticalSe...
)

Constructor that tries to lock the critical section.

Destructors

Name Description

Public function

~FScopeTryLock()

Destructor that will release the lock if it was ever acquired.

Functions

Name Description

Public function Const

bool

 

IsLocked()

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss