laforge49/JActor — Issue #11: speed up JAEventQueue
Author: laforge49
Created: 2012-02-25 04:13:12+00:00
State: open

A small change to JAEventQueue should give us much better timings. Here's the code that needs improving:

public boolean acquireControl(EventQueue eventQueue) {
if (atomicControl.compareAndSet(null, eventQueue.getController())) {
notEmpty = false;
return true;
}
return false;
}

We need to add a faster check before the if statement:

public boolean acquireControl(EventQueue eventQueue) {
if (atomicConttrol.get() != null) ||
atomicControl.compareAndSet(null, eventQueue.getController()) {
notEmpty = false;
return true;
}
return false;
}