ark::core::ScopeExit

Defined in header “ark/core/scope_exit.hh”.


A simple class that allows you to invoke code once the scope is exiting. This is useful as a ‘finally’ type concept, where you want to ensure some code is run, even if an exception occurs.

Methods

  • ScopeExit(Callback callback)
    Constructor. The specified function will be invoked in the destructor.

  • ~ScopeExit()
    Destructor. Invokes the provided callback.

  • void complete()
    Forces execution fo the scope exit immediately, rather than at destruction time.

  • void cancel()
    Cancels the scope exit; the callback will not be executed, even if complete() is invoked.