MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Mcro::Finally::FFinally Struct Reference

#include <Finally.h>

Inheritance diagram for Mcro::Finally::FFinally:

Public Member Functions

 FFinally (TUniqueFunction< void()> &&payload)
 
 FFinally (FFinally &&from) noexcept
 
 ~FFinally ()
 

Detailed Description

Run arbitrary finalizers on destruction. It has similar purpose to ON_SCOPE_EXIT, however FFinally can be moved around into different scopes, Payload will be only executed if the finalizer hasn't been moved from, otherwise the payload will be ignored in the source of move assignments:

{ FFinally fin([] {...}) Async(EAsyncExecution::ThreadPool, [fin = MoveTemp(fin)] { // Payload is executed at the end of this scope } // Payload is not executed here }

Finalizers can be moved into nested scopes

{ FFinally fin([] {...}) Async(EAsyncExecution::ThreadPool, [fin = MoveTemp(fin)] mutable { AsyncTask(ENamedThreads::GameThread, [fin = MoveTemp(fin)] { // Payload is executed at the end of this scope } // Payload is not executed here } // Payload is not executed here }

Definition at line 46 of file Finally.h.

Constructor & Destructor Documentation

◆ FFinally() [1/2]

Mcro::Finally::FFinally::FFinally ( TUniqueFunction< void()> && payload)
inline

Definition at line 53 of file Finally.h.

◆ FFinally() [2/2]

Mcro::Finally::FFinally::FFinally ( FFinally && from)
inlinenoexcept

Definition at line 54 of file Finally.h.

◆ ~FFinally()

Mcro::Finally::FFinally::~FFinally ( )
inline

Definition at line 59 of file Finally.h.


The documentation for this struct was generated from the following file: