[DGD] atomic functions

Felix A. Croes felix at dworkin.nl
Wed Aug 1 14:17:35 CEST 2001


pete at ana.sk wrote:

> Just a question (and maybe suggestion). Is there a way how to 
> cancel execution of atomic function (and return something from 
> that finctions as result too) without making error? I have not found 
> any...
> And if im right and there is nothing for it, would not it be good to 
> have something like that? Maybe "abort" statement, that will act as 
> return from atomic function, only it will also rollback everything 
> done? Something like
>
> atomic int do_something() /* return 1 ok, 0 aborted */
> {
> 	...
> 	if(some condition)
> 		abort 0;
> 	...
> 	return 1;
> }
>
> ..
> if(do_something())
> {
> 	/* It worked! */
> 	...
> }

    atomic int do_something()
    {
        ...
        if (some_condition) {
            error("abort");
        }
        ...
        return 1;
    }

    int catch_something()
    {
        catch {
            return do_something();
        } : {
	    return 0;
        }
    }

Easily extended if you only want to do this for a certain type of errors.

The reason for not allowing a return of arbitrary data out of an aborted
atomic function is that it could refer to data (objects) that does not
exist outside of the atomic context.  This is not going to change.

Regards,
Dworkin
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list