2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
6 package TransactionalIO.core;
8 import TransactionalIO.core.ExtendedTransaction;
10 import TransactionalIO.core.CustomThread;
11 import TransactionalIO.interfaces.TransactionStatu;
12 import java.util.Vector;
22 private ExtendedTransaction transaction = new ExtendedTransaction();
23 private static ThreadLocal IOtransactioncontainer = new ThreadLocal();
24 private static ThreadLocal onMemoryAbort = new ThreadLocal();
25 private static ThreadLocal onIOAbort = new ThreadLocal();
29 public static void prepareIOCommit(){
31 getTransaction().prepareCommit();
34 public static void commitIO(){
35 getTransaction().commitChanges();
40 public static void Initialize(TransactionStatu memory){
41 ExtendedTransaction transaction = new ExtendedTransaction();
42 setTransaction(transaction);
43 transaction.setOtherSystem(memory);
46 memory.setOtherSystem(transaction);
50 /* setonIOAbort(new Vector());
51 setonMemoryAbort(new Vector());
53 getonIOAbort().add(new terminateHandler() {
54 public void cleanup() {
55 Thread.getTransaction().abort();
56 synchronized(benchmark.lock){
57 System.out.println(Thread.currentThread() +" KEWL");
62 getonMemoryAbort().add(new terminateHandler() {
63 public void cleanup() {
64 CustomThread.getTransaction().abort();
65 synchronized(benchmark.lock){
66 System.out.println(Thread.currentThread() +" KEWL");
72 public static void memoryCommit(){
77 public static void setTransaction(ExtendedTransaction transaction){
78 IOtransactioncontainer.set(transaction);
83 public static ExtendedTransaction getTransaction(){
84 return (ExtendedTransaction) IOtransactioncontainer.get();
87 public static void setonIOAbort(Vector vec){
92 private static Vector getonIOAbort(){
93 return (Vector) onIOAbort.get();
96 public static void setonMemoryAbort(Vector vec){
97 onMemoryAbort.set(vec);
101 private static Vector getonMemoryAbort(){
102 return (Vector) onMemoryAbort.get();