Last active
August 29, 2015 14:16
-
-
Save jfarcand/f890b0f8218af3c5d8c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void queueWriteIO(AtmosphereResource r, Deliver deliver, AtomicInteger count) throws InterruptedException { | |
if (deliver.async) { | |
// The onStateChange/onRequest may change the isResumed value, hence we need to make sure only one thread flip | |
// the switch to garantee the Entry will be cached in the order it was broadcasted. | |
// Without synchronizing we may end up with a out of order BroadcasterCache queue. | |
if (!bc.getBroadcasterCache().getClass().equals(BroadcasterCache.DEFAULT.getClass().getName())) { | |
if (r.isResumed() || r.isCancelled()) { | |
logger.trace("AtmosphereResource {} has been resumed or cancelled, unable to Broadcast message {}", r.uuid(), deliver.message); | |
/** | |
* Check in the cache again ##issue | |
*/ | |
AtmosphereResource r2 = config.resourcesFactory().find(r.uuid()); | |
if (r2 != null && r2.isSuspended() && r.hashCode() != r2.hashCode()) { | |
// Prevent other Broadcast to happens | |
removeAtmosphereResource(r2); | |
checkCachedAndPush(r2, r2.getAtmosphereResourceEvent()); | |
} | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment