Exemple #1
0
 static void dispatchAction(Action action) {
   LockingTransaction trans = LockingTransaction.getRunning();
   if (trans != null) trans.enqueue(action);
   else if (nested.get() != null) {
     nested.set(nested.get().cons(action));
   } else action.agent.enqueue(action);
 }
  public static Object runInTransaction(Callable fn) throws Exception {
    LockingTransaction t = transaction.get();
    if (t == null) transaction.set(t = new LockingTransaction());

    if (t.info != null) return fn.call();

    return t.run(fn);
  }
  public static Object runInTransaction(Callable fn) throws Exception {
    LockingTransaction t = transaction.get();
    Object ret;
    if (t == null) {
      transaction.set(t = new LockingTransaction());
      try {
        ret = t.run(fn);
      } finally {
        transaction.remove();
      }
    } else {
      if (t.info != null) {
        ret = fn.call();
      } else {
        ret = t.run(fn);
      }
    }

    return ret;
  }