Boost logo

Boost :

Subject: Re: [boost] [transact] code in sandbox
From: strasser_at_[hidden]
Date: 2010-02-17 09:29:56


Zitat von Bob Walters <bob.s.walters_at_[hidden]>:
>>> when the user needs to have control over code-on-retry etc., using the
>>> macros is not less verbose and the user has to be aware of the details
>>> that this is implemented as a loop and a try/catch block.
>>> having more than one choice on which macro to use even adds complexity.
>>
>> Maybe you are right, may be not. All these depend on whether we found a good
>> macro name for each common use case. I hope we will find out these common
>> use cases and appropriated names together.
>
> I agree with Steffan on this point.

I don't agree with me anymore ;)
I still do in principle, but the macro has grown a little more complex
in our discussion, to support "break", "return" and "continue" inside
of user loops. so when you're weighing using a macro against writing a
loop yourself it is now more tilted towards using a macro, so maybe we
should support something like BOOST_TRANSACT_ON_RETRY.

control ctrl;
while(true){
   try{
     transaction tx;
     commit_on_destruction destr(tx);
     try{
       do{
         ctrl=break_;

         //...user code
         if(something) break;
         else if(something_else) continue;
         else return 5;
         //...end user code

         ctrl=none;
         break;
       }while((ctrl=continue_),false);
     }catch(...){
       destr.nullify();
       throw;
     }
     break;
   }catch(isolation_exception &){}
};
if(ctrl==continue_) continue;
else if(ctrl==break_) break;


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