Skip to content

Commit

Permalink
Optimizing AbstractPromise to avoid initial CAS
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorklang committed Apr 26, 2012
1 parent fbb3356 commit 0a5d5f7
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions akka-actor/src/main/java/akka/dispatch/AbstractPromise.java
Expand Up @@ -7,14 +7,9 @@
import akka.util.Unsafe;

abstract class AbstractPromise {
private volatile Object _ref;
private volatile Object _ref = DefaultPromise.EmptyPending();

{
if (!updateState(null, DefaultPromise.EmptyPending()))
throw new ExceptionInInitializerError(new IllegalStateException("AbstractPromise initial value not null!"));
}

final static long _refOffset;
final static long _refOffset; // Memory offset to _ref field

static {
try {
Expand All @@ -29,6 +24,6 @@ protected final boolean updateState(Object oldState, Object newState) {
}

protected final Object getState() {
return Unsafe.instance.getObjectVolatile(this, _refOffset);
return _ref;
}
}

0 comments on commit 0a5d5f7

Please sign in to comment.