DeuceSTM and Futures

78 views
Skip to first unread message

José Pereira

unread,
Nov 3, 2013, 4:43:46 PM11/3/13
to deuce-stm-...@googlegroups.com
Hey,

Simple question, does Deuce support the use of java.util.concurrent classes, for example Futures?
I tried this simple test program, that runs the following method:

   @Atomic(retries=1)
    public void addvalue() {
        mapa.add("aaa");
    ExecutorService exeService = Executors.newFixedThreadPool(10);
        FutureTask<Integer> future = new FutureTask<Integer>(
                new Callable<Integer>()
                {
                    public Integer call()
                    {
                        return addvalue2();
                    }
                });
        exeService.execute(future);
    try{
           System.out.println(future.get());
    }catch(Exception e) {}
    exeService.shutdown();
    throw new TransactionException("Key not found");
    }

    public Integer addvalue2(){
         mapa.add("bbb");
        return 1;
    }

I instrumented the rt.jar and my program, tried to run and it throws the following exception:

Exception in thread "Thread-0" java.lang.ExceptionInInitializerError
    at java.lang.System.getSecurityManager(System.java:325)
    at java.util.concurrent.Executors$DefaultThreadFactory.<init>(Executors.java:563)
    at java.util.concurrent.Executors.defaultThreadFactory(Executors.java:317)
    at java.util.concurrent.ThreadPoolExecutor.<init>(ThreadPoolExecutor.java:1199)
    at java.util.concurrent.Executors.newFixedThreadPool(Executors.java:89)
    at Main2.addvalue(Main2.java:25)
    at Main2.addvalue(Main2.java)
    at Main2.run(Main2.java:18)
    at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.NoSuchFieldException: security
    at java.lang.Class.getDeclaredField(Class.java:1929)
    at java.lang.SystemDeuceFieldsHolder.<clinit>(Unknown Source)
    ... 9 more

Also, if Deuce supports this classes, what does it happen? I mean, what method does the thread created by the future run, addvalue2() (no transaction)  or an instrumented version of addvalue2() (in the context of a transaction)? Does that same thread run as a nested transaction or a new distinct transaction that can commit without waiting for the transaction that created the future?


Thx in advance.

Guy Korland

unread,
Nov 4, 2013, 4:27:48 PM11/4/13
to deuce-stm-developers

Concurrent lib heavily relay on CAS  which is usually done using Unsafe. Deuce currently only support field access using "standard" way, and not using native code.
Deuce instrumentation can be easily extended to support such assignments.

--
You received this message because you are subscribed to the Google Groups "Deuce-STM developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deuce-stm-develo...@googlegroups.com.
To post to this group, send email to deuce-stm-...@googlegroups.com.
Visit this group at http://groups.google.com/group/deuce-stm-developers.
For more options, visit https://groups.google.com/groups/opt_out.

José Pereira

unread,
Nov 9, 2013, 7:10:10 PM11/9/13
to deuce-stm-...@googlegroups.com
Thank you for your response. Either way, is it possible to use the original Futures classes (not instrumented ones) inside a Deuce transaction? I don't care about conflict detection, as in i'm ok with weak isolation. I would like to just make a deuce thread start a future and then block when it calls the get() method, with all the original future's semantics.
I tried to add java.util.concurrent to the -Dorg.deuce.exclude list but it throws some java.lang.NoClassDefFoundError:Main$1 exception, being Main the class where the future is used.

Thank you in advance.
To unsubscribe from this group and stop receiving emails from it, send an email to deuce-stm-developers+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages