Boost logo

Boost :

From: Hans Larsen (hans_at_[hidden])
Date: 2007-04-11 16:13:08


Hello Andrey.

On 9-Apr-07, at 12:56 PM, Andrey Semashev wrote:

> Hello Alexander,
>
> Monday, April 9, 2007, 10:46:24 AM, you wrote:
>
>> Andrey Semashev wrote:
>>> Another good use case for scope guards is making rollbackable code.
>>> But I see, this implementation doesn't support that.
>
>> bool rollback = true;
>> // ...
>
>> BOOST_SCOPE_EXIT( (rollback) )
>> {
>> if(rollback) do_rollback();
>> }
>> BOOST_SCOPE_EXIT_END
>
>> // ...
>> rollback = false; // commit
>
> Yes, that is possible. Obviously, I didn't express myself well. I
> meant, it doesn't have a special support for it. What I was thinking
> is somewhat like this:
>
> guard_stack transaction;
>
> for (int i = 0; i < n; ++i)
> {
> do_smth(i);
> transaction.push(bind(&undo_smth, i));
> }
>
> transaction.commit();
>
> IMHO, this looks a little more cute.

Although I admit such an addition to the library would be great,
IMHO, this is outside the scope of the functionality planned here.
Why not a Boost.Transaction library? What do you think?

Hans

>
> --
> Best regards,
> Andrey mailto:andysem_at_[hidden]
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/
> listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk