#include <emanaged.h>
class LCleanedupGuard |
Public Member Functions | |
---|---|
LCleanedupGuard(TCleanupOperation, TAny *) | |
~LCleanedupGuard() | |
void | Cleanup(TAny *) |
void | Dismiss() |
void | Execute() |
A class that provides CleanupStack-based local-scope automatic cleanup using a TCleanupOperation on the destruction of the LManagedGuard object.
This class can only be used to define a local stack scoped cleanup, never an object scoped cleanup to guard object destruction. See below for an explanation and links to management classes suitable for use in different contexts.
The guarding local variable goes out of scope normally
The guarding local variable goes out of scope due to an untrapped leave causing the scope to be exited non-locally
The constructors of this class may leave.
Automatic cleanup may be disabled at any time by calling Dismiss(), while cleanup may be forced at any time by calling Execute().
// block scope example { RCleanable obj; LCleanedupGuard cleanGuard(RCleanable::Cleanup, &obj); obj.DoSomethingL(); // leave-safe if (Finished()) return; // RCleanable::Cleanup is invoked automatically when exiting from scope obj.DoSomethingElseL(); // leave-safe // RCleanable::Cleanup is invoked automatically when exiting from scope }
Behind the scenes, this class template is implemented in terms of the thread-local CleanupStack, restricting its use to local stack scope. This use of the CleanupStack ensures a consistent cleanup order between functions that call one another, even if they use different cleanup idioms.
See also: LManagedGuard which has the same interface, but does not use the cleanup stack and is suitable for use as the data member of a class to guard object destruction.
LCleanedupGuard | ( | TCleanupOperation | aCleanupOperation, |
TAny * | aData = 0 | ||
) | [inline] |
Constructor. Creates a LCleanedupGuard object that, when enabled, automatically invokes upon destruction a cleanup operation specified by the aCleanupOperation parameter with the pointer to data specified by the aData parameter.
Parameters | |
---|---|
aCleanupOperation | A cleanup operation. |
aData | Pointer to data to be passed to the cleanup operation |