From e4a4451533968e0a802580476f957c4b10c2e807 Mon Sep 17 00:00:00 2001 From: jboner Date: Fri, 4 Sep 2009 15:25:42 +0200 Subject: [PATCH] deleted old project files --- util-java/akka-util-java.iml | 18 -- .../akka/kernel/stm/Ref.java | 251 ------------------ 2 files changed, 269 deletions(-) delete mode 100644 util-java/akka-util-java.iml delete mode 100644 util-java/src/main/java/se/scalablesolutions/akka/kernel/stm/Ref.java diff --git a/util-java/akka-util-java.iml b/util-java/akka-util-java.iml deleted file mode 100644 index 646310bd42..0000000000 --- a/util-java/akka-util-java.iml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/util-java/src/main/java/se/scalablesolutions/akka/kernel/stm/Ref.java b/util-java/src/main/java/se/scalablesolutions/akka/kernel/stm/Ref.java deleted file mode 100644 index 8207d7d20b..0000000000 --- a/util-java/src/main/java/se/scalablesolutions/akka/kernel/stm/Ref.java +++ /dev/null @@ -1,251 +0,0 @@ -package se.scalablesolutions.akka.kernel.stm; - -import static org.multiverse.api.StmUtils.retry; -import org.multiverse.api.Transaction; -import org.multiverse.api.exceptions.LoadUncommittedAtomicObjectException; -import org.multiverse.api.exceptions.ReadonlyException; -import org.multiverse.datastructures.refs.ManagedRef; -import org.multiverse.stms.alpha.*; -import org.multiverse.stms.alpha.mixins.FastAtomicObjectMixin; -import org.multiverse.templates.AtomicTemplate; -import org.multiverse.datastructures.refs.manual.*; - -/** - * A manual instrumented {@link org.multiverse.datastructures.refs.ManagedRef} implementation. - * If this class is used, you don't need to worry about instrumentation/javaagents and - * stuff like this. - * - * It is added to get the Akka project up and running, but probably will removed when the instrumentation - * is 100% up and running and this can be done compiletime instead of messing with javaagents. - * - * @author Peter Veentjer - */ -public final class Ref extends FastAtomicObjectMixin implements ManagedRef { - - public Ref() { - new AtomicTemplate() { - @Override - public Object execute(Transaction t) throws Exception { - - ((Transaction) t).attachNew(new RefTranlocal(Ref.this)); - return null; - } - }.execute(); - } - - public Ref(Transaction t) { - ((Transaction) t).attachNew(new RefTranlocal(Ref.this)); - } - - public Ref(final E value) { - new AtomicTemplate() { - @Override - public Object execute(Transaction t) throws Exception { - ((Transaction) t).attachNew(new RefTranlocal(Ref.this, value)); - return null; - } - }.execute(); - } - - public Ref(Transaction t, final E value) { - ((Transaction) t).attachNew(new RefTranlocal(Ref.this, value)); - } - - public E get() { - return new AtomicTemplate() { - @Override - public E execute(Transaction t) throws Exception { - RefTranlocal tranlocalRef = (RefTranlocal) ((Transaction) t).privatize(Ref.this); - return tranlocalRef.get(); - } - }.execute(); - } - - public E get(Transaction t) { - RefTranlocal tranlocalRef = (RefTranlocal) ((Transaction) t).privatize(Ref.this); - return tranlocalRef.get(); - } - - @Override - public E getOrAwait() { - return new AtomicTemplate() { - @Override - public E execute(Transaction t) throws Exception { - RefTranlocal tranlocalRef = (RefTranlocal) ((Transaction) t).privatize(Ref.this); - return tranlocalRef.getOrAwait(); - } - }.execute(); - } - - public E getOrAwait(Transaction t) { - RefTranlocal tranlocalRef = (RefTranlocal) ((Transaction) t).privatize(Ref.this); - return tranlocalRef.getOrAwait(); - } - - - @Override - public E set(final E newRef) { - System.out.println("------------- REF SET 1: " + newRef); - return new AtomicTemplate() { - @Override - public E execute(Transaction t) throws Exception { - System.out.println("------------- REF SET 2: " + newRef); - System.out.println("------------- TX: " + t); - RefTranlocal tranlocalRef = (RefTranlocal) ((Transaction) t).privatize(Ref.this); - return tranlocalRef.set(newRef); - } - }.execute(); - } - - public E set(Transaction t, final E newRef) { - RefTranlocal tranlocalRef = (RefTranlocal) ((Transaction) t).privatize(Ref.this); - return tranlocalRef.set(newRef); - } - - @Override - public boolean isNull() { - return new AtomicTemplate() { - @Override - public Boolean execute(Transaction t) throws Exception { - RefTranlocal tranlocalRef = (RefTranlocal) ((Transaction) t).privatize(Ref.this); - return tranlocalRef.isNull(); - } - }.execute(); - } - - public boolean isNull(Transaction t) { - RefTranlocal tranlocalRef = (RefTranlocal) ((Transaction) t).privatize(Ref.this); - return tranlocalRef.isNull(); - } - - @Override - public E clear() { - return new AtomicTemplate() { - @Override - public E execute(Transaction t) throws Exception { - RefTranlocal tranlocalRef = (RefTranlocal) ((Transaction) t).privatize(Ref.this); - return tranlocalRef.clear(); - } - }.execute(); - } - - public E clear(Transaction t) { - RefTranlocal tranlocalRef = (RefTranlocal) ((Transaction) t).privatize(Ref.this); - return tranlocalRef.clear(); - } - - @Override - public RefTranlocal privatize(long readVersion) { - RefTranlocal origin = (RefTranlocal) load(readVersion); - if (origin == null) { - throw new LoadUncommittedAtomicObjectException(); - } - return new RefTranlocal(origin); - } -} - -class RefTranlocal extends Tranlocal { - //field belonging to the stm. - Ref atomicObject; - RefTranlocal origin; - - E ref; - - RefTranlocal(RefTranlocal origin) { - this.version = origin.version; - this.atomicObject = origin.atomicObject; - this.ref = origin.ref; - this.origin = origin; - } - - RefTranlocal(Ref owner) { - this(owner, null); - } - - RefTranlocal(Ref owner, E ref) { - this.version = Long.MIN_VALUE; - this.atomicObject = owner; - this.ref = ref; - } - - @Override - public AlphaAtomicObject getAtomicObject() { - return atomicObject; - } - - public E clear() { - E oldValue = ref; - ref = null; - return oldValue; - } - - public boolean isNull() { - return ref == null; - } - - public E get() { - return ref; - } - - public E set(E newValue) { - if (committed) { - throw new ReadonlyException(); - } - E oldValue = ref; - this.ref = newValue; - return oldValue; - } - - public E getOrAwait() { - if (isNull()) { - retry(); - } - - return ref; - } - - @Override - public void prepareForCommit(long writeVersion) { - this.version = writeVersion; - this.committed = true; - this.origin = null; - } - - @Override - public TranlocalSnapshot takeSnapshot() { - return new RefTranlocalSnapshot(this); - } - - @Override - public DirtinessStatus getDirtinessStatus() { - if (committed) { - return DirtinessStatus.committed; - } else if (origin == null) { - return DirtinessStatus.fresh; - } else if (origin.ref != this.ref) { - return DirtinessStatus.dirty; - } else { - return DirtinessStatus.clean; - } - } -} - -class RefTranlocalSnapshot extends TranlocalSnapshot { - final RefTranlocal tranlocal; - final E value; - - RefTranlocalSnapshot(RefTranlocal tranlocal) { - this.tranlocal = tranlocal; - this.value = tranlocal.ref; - } - - @Override - public Tranlocal getTranlocal() { - return tranlocal; - } - - @Override - public void restore() { - tranlocal.ref = value; - } -}