Use laxySet() when returning pool entries.

pull/408/head
Brett Wooldridge 10 years ago
parent 4639ca0bfb
commit afe1527039

@ -155,6 +155,13 @@ public final class PoolEntry implements IConcurrentBagEntry
return state.compareAndSet(expect, update);
}
/** {@inheritDoc} */
@Override
public void lazySet(int update)
{
state.lazySet(update);
}
/** {@inheritDoc} */
@Override
public String toString()

@ -72,7 +72,8 @@ public class ConcurrentBag<T extends IConcurrentBagEntry> implements AutoCloseab
int STATE_REMOVED = -1;
int STATE_RESERVED = -2;
boolean compareAndSet(int from, int to);
boolean compareAndSet(int expectState, int newState);
void lazySet(int newState);
int getState();
}
@ -173,17 +174,14 @@ public class ConcurrentBag<T extends IConcurrentBagEntry> implements AutoCloseab
@SuppressWarnings("unchecked")
public void requite(final T bagEntry)
{
if (bagEntry.compareAndSet(STATE_IN_USE, STATE_NOT_IN_USE)) {
final List threadLocalList = threadList.get();
if (threadLocalList != null) {
threadLocalList.add((weakThreadLocals ? new WeakReference<>(bagEntry) : bagEntry));
}
bagEntry.lazySet(STATE_NOT_IN_USE);
synchronizer.signal();
}
else {
LOGGER.warn("Attempt to remove an object from the bag that does not exist: {}", bagEntry);
final List threadLocalList = threadList.get();
if (threadLocalList != null) {
threadLocalList.add((weakThreadLocals ? new WeakReference<>(bagEntry) : bagEntry));
}
synchronizer.signal();
}
/**

Loading…
Cancel
Save