Programmatic Interface?

9 views
Skip to first unread message

Saxo

unread,
Nov 17, 2011, 4:47:06 PM11/17/11
to Deuce-STM developers
Hello,

I would like to ask whether Deuce also provides some programmatic
interface, e.g. something like this:

while(!success)
try {
Transaction trx = Transaction.begin();
ValueHolder valueHolder = STM.load("myKey");
valueHolder.value = 123;
STM.put("myKey");
trx.commit();
success = true;
}
catch(OptimisticLockingException e)
{
// retry n times
}

Reason is that it would be nice if Deuce STM could be accessed from a
remote JVM when being used in a distributed setting.

Regards, Saxo

Guy Korland

unread,
Nov 17, 2011, 5:31:58 PM11/17/11
to deuce-stm-...@googlegroups.com
No, Deuce isn't supporting explicit calls.
But, this can be easily done using the transaction Context directly.
If you'll review the AtomicMethod.java code you can see how deuce is doing it behind the scenes. 

        /**
        public static boolean foo(Object s) throws IOException{

                Throwable throwable = null;
                Context context = ContextDelegator.getInstance();
                boolean commit = true;
                boolean result = true;
                for( int i=10 ; i>0 ; --i)
                {
                        context.init(atomicBlockId, metainf);
                        try
                        {
                                result = foo(s,context);
                        }
                        catch( AbortTransactionException ex)
                        {
                                context.rollback();
                                throw ex;
                        }
                        catch( TransactionException ex)
                        {
                                commit = false;
                        }
                        catch( Throwable ex)
                        {
                                throwable = ex;
                        }

                        if( commit )
                        {
                                if( context.commit()){
                                        if( throwable != null)
                                                throw (IOException)throwable;
                                        return result;
                                }
                        }
                        else
                        {
                                context.rollback();
                                commit = true;
                        }
                }
                throw new TransactionException();

        }
         */


Regards,
Guy Korland



--
You received this message because you are subscribed to the Google Groups "Deuce-STM developers" group.
To post to this group, send email to deuce-stm-...@googlegroups.com.
To unsubscribe from this group, send email to deuce-stm-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/deuce-stm-developers?hl=en.


Reply all
Reply to author
Forward
0 new messages