folly::Cleanup

Base class for structured async cleanup.

Synopsis

Declared in <folly/futures/Cleanup.h>

class Cleanup;

Description

This implementation is a base class that collects a set of cleanup tasks and runs them in reverse order.

A class derived from Cleanup

  • only allows cleanup to be run once

  • is required to complete cleanup before running the destructor

  • should not run cleanup tasks. Running the cleanup task should be delegated to the owner of the derived class

  • should not be owned by a shared_ptr. Cleanup is intended to remove shared ownership.

Member Functions

NameDescription
Cleanup [constructor]Constructs a Cleanup with an empty set of cleanup tasks.
~Cleanup [destructor]Destroys the Cleanup, requiring that cleanup() has already completed.
cleanup Runs the accumulated cleanup tasks in reverse of the order they were added.

Protected Member Functions

NameDescription
addCleanup addCleanup overloads