Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit b7ce156d authored by Lloyd Pique's avatar Lloyd Pique
Browse files

Introduce ftl::Finalizer{<F>,Std,Ftl,Ftl1,Ftl2,Ftl3}

A Finalizer ensures a final cleanup function is executed when it is
destroyed. The cleanup can also be explicitly invoked before
destruction, or canceled so it is not executed.

As they are meant for one-time cleanup, Finalizers are moveable but not
copyable.

The templated `Finalizer<F>` can be constructed from any function object
that can be invoked with no arguments and that returns void. If `F` can
be default constructed, then `Finalizer<F>` can be default constructed.

`ftl::FinalizerStd` is an alias that uses `std::function` as the
function object type. `ftl::FinalizerFtl`, `ftl::FinalizerFtl1`,
`ftl::FinalizerFtl2` and `ftl::FinalizerFtl3` are aliases that use
`ftl::Function` as the type, with increasing amounts of fixed-size
internal storage for captured values. These are useful when specifying a
return type or a storage type, and are all default-construcible.

Bug: 185536303
Flag: EXEMPT New library code
Test: atest ftl_test
Change-Id: If4a130873ae38727e5bafd634344ae341640e742
parent 9bf3e87d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment