comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Handling transactions?
Date: Tue, 28 Jul 2015 15:23:46 -0500
Date: 2015-07-28T15:23:46-05:00	[thread overview]
Message-ID: <mp8ock$5hv$1@loke.gir.dk> (raw)
In-Reply-To: xrh840crgak6$.og5ru41qaz0o$.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:xrh840crgak6$.og5ru41qaz0o$.dlg@40tude.net...
> On Mon, 27 Jul 2015 19:10:09 -0500, Randy Brukardt wrote:
>
>> This is typically used in a block:
>>
>>     declare
>>          My_Lock : Lock; -- Gets lock.
>>     begin
>>          -- Do operations needing the lock.
>>     end; -- The lock is freed here, no matter how this block is 
>> completed.
>>
>> I suspect that you could use a similar pattern for transactions (although
>> I've never tried it).
>
> Yes, the way I did it was similar:
>
>   declare
>      My_Transaction : Transaction (...);
>   begin
>      -- Do operations
>      Commit (My_Transaction);
>   end;
>
> The transaction object has the flag Committed set by Commit. Upon an
> exception the flag remains not set and Finalize rolls back. Without an
> exception the flag is set and Finalize commits.

Looks good to me.

> The problem with this approach is that you cannot propagate exceptions on
> errors from Finalize when commit or rollback fails.

Well, you can if your only intent is to kill the program (Finalize will 
cause Program_Error to be raised -- somewhere -- if it propagates an 
exception). If you want to do recovery of some sort, it would be a problem. 
(Off-hand, I'm not sure what recovery one can do when rollback fails, and 
the recovery from a commit failure seems to be to rollback, so it seems that 
killing the program is the primary goal. But of course YMMV.)

                           Randy.


  reply	other threads:[~2015-07-28 20:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27 12:21 Handling transactions? EGarrulo
2015-07-27 14:16 ` Björn Lundin
2015-07-27 14:38   ` EGarrulo
2015-07-27 14:53     ` Simon Wright
2015-07-27 16:38       ` David Botton
2015-07-27 18:15         ` EGarrulo
2015-07-28  0:10           ` Randy Brukardt
2015-07-28  5:33             ` J-P. Rosen
2015-07-28  6:45             ` Dmitry A. Kazakov
2015-07-28 20:23               ` Randy Brukardt [this message]
2015-07-28  2:41         ` Norman Worth
2015-07-29  6:51 ` Jacob Sparre Andersen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox