FGantryLoadScopeGuard
C++ helper that opens a load scope when it is created and closes it when it goes out of scope.
Use it in synchronous code with several early returns, where a missed CloseScope would leave a scope open and the loading screen up:
FGantryLoadScopeGuard ;
if // still closed, marked Failed
Async work outlives the stack frame. For that, open the scope on FGantryLoadLedger and close it from the completion delegate, or hand the guard's scope over with Release.
In Blueprint, use Begin Load Scope and End Load Scope instead.
Members
FGantryLoadScopeGuard
Opens a scope on the module ledger, taking the same arguments as FGantryLoadLedger::OpenScope.
If the ledger is unavailable the guard owns nothing and every method is a no-op.
~FGantryLoadScopeGuard
Closes the owned scope as Failed, Cancelled or Completed, unless Release gave it away.
FGantryLoadScopeGuard
Not copyable: a scope must be closed exactly once.
Move-construct to transfer ownership.
operator=
FGantryLoadScopeGuard &
Not assignable, by copy or by move: a guard keeps the scope it was constructed with.
FGantryLoadScopeGuard
Takes over Other's scope and final state; Other is left owning nothing.
GetHandle
FGantryHandle
Returns the guarded scope's handle, e.g.
to parent child scopes; invalid if none is owned.
AttachHandle
void
Attaches a streamable handle to the guarded scope.
Ignored when the guard owns nothing.
Fail
void
Marks the scope failed.
It still closes on destruction.
Cancel
void
Marks the scope cancelled.
It still closes on destruction.
Release
FGantryHandle
Gives up ownership without closing, for handing the scope to an async continuation.
The caller becomes responsible for closing it.
Returns: The scope's handle, or an invalid handle if the guard owned nothing.