commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject [pool] excessive synch scope when checking for allocated latches?
Date Wed, 13 Jan 2010 12:50:29 GMT
GOP and GKOP both use the following idiom in several places to check
to see if an instance has been allocated to a thread:

synchronized (this) {
// Make sure allocate hasn't already assigned an object
// in a different thread or permitted a new object to be created
    if (latch.getPair() == null && !latch.mayCreate()) {
        _allocationQueue.remove(latch);
    } else {
          break;
    }
}

Couldn't the check on latch state be synched just on the latch (and
then acquire the pool lock only if there is something to remove)?


Phil

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message