Boost logo

Boost :

From: Andrey Semashev (andysem_at_[hidden])
Date: 2005-09-04 17:49:58

I've made some reworks and additions to my previously presented version of
generalized scope guards. To be short, here are brief changes:
- Scope guard creation has moved to make_* functions instead of explicitly
creating a scope guard object.
- Now not using the Boost.Function to hold functors. The functor type is
detected in make_* creating functions. This gave a considerable perfomance
gain especially in simple tests where guard creation/destruction takes large
amount of the time comparing to the useful work.
- Unified scope guard variable declaration, regardless of the type of the
guard (destruction guard or construction/destruction guard). In fact only a
reference to a base class is declared, so it may be bound to any type of
guards returned by the make_* function. As a result users' code shall be
- Several internal changes, including BOOST_NO_EXCEPTIONS awareness,
Boost.Preprocessor usage instead of self-made analogues and others.
- Basic transactions support. Actually, the construction/destruction guards
are created by make_transaction function, so the construction functor has
the semantic of action, and the destruction functor - of rollback or undo
action. Disarming such guard has the semantic of committing actions.
- Added a simple actions trace class (in a separate file). It can be used
with scope guards to perform complex transactions. In other words, when
executing a complex action that consists of several discardable subactions
this trace class allows to massively commit or rollback these subactions.

I've tested this version with VC 7.1, ICL 9.0 and GCC 3.4.4 (MinGW version).
The sources with some instructions (in .h-files) and a small test, which may
be used as an example, are in the Sandbox:

A few word of what I'm not sure of:
- The naming of classes/functions/macroses. They look quite simple to me,
but maybe someone has better proposals? Especially it concerns macroses (may
be some prefixes?).
- It would be great if someone tried it on some other compilers - VC 6, for
example. It should work, but I don't have the compiler to be sure.
- Is there still interest in this implementation or the multi_index version
is finally chosen to be Boost.ScopeGuard?

PS: I'm really sorry for such a long delay. I was rather busy for last few

Boost list run by bdawes at, gregod at, cpdaniel at, john at