private boolean offerImpl(T t) { long oldState = reserveArrayIndex(EMPTY, OBJECTS); if (oldState == NO_INDEX) return false; // For whatever reason, reserve failed. long originalMarker = EMPTY.getMarker(oldState), delta = EMPTY.getDelta(oldState); int arrayIndex = (int)getArrayIndex(originalMarker, delta); if (pool[arrayIndex] != null) { throwError(oldState, arrayIndex, "non-null"); } pool[arrayIndex] = t; commitArrayIndex(EMPTY, OBJECTS, originalMarker); return true; }
private T takeImpl() { long oldState = reserveArrayIndex(OBJECTS, EMPTY); if (oldState == NO_INDEX) return null; // For whatever reason, reserve failed. long originalMarker = OBJECTS.getMarker(oldState), delta = OBJECTS.getDelta(oldState); int arrayIndex = (int)getArrayIndex(originalMarker, delta); T result = pool[arrayIndex]; if (result == null) { throwError(oldState, arrayIndex, "null"); } pool[arrayIndex] = null; commitArrayIndex(OBJECTS, EMPTY, originalMarker); return result; }
private boolean offerImpl(T t) { long oldState = reserveArrayIndex(EMPTY, OBJECTS); if (oldState == NO_INDEX) return false; // For whatever reason, reserve failed. long originalMarker = EMPTY.getMarker(oldState), delta = EMPTY.getDelta(oldState); int arrayIndex = (int)getArrayIndex(originalMarker, delta); if (pool[arrayIndex] != null) { throwError(oldState, arrayIndex, "non-null"); } pool[arrayIndex] = t; commitArrayIndex(EMPTY, OBJECTS, originalMarker); return true; }
private T takeImpl() { long oldState = reserveArrayIndex(OBJECTS, EMPTY); if (oldState == NO_INDEX) return null; // For whatever reason, reserve failed. long originalMarker = OBJECTS.getMarker(oldState), delta = OBJECTS.getDelta(oldState); int arrayIndex = (int)getArrayIndex(originalMarker, delta); T result = pool[arrayIndex]; if (result == null) { throwError(oldState, arrayIndex, "null"); } pool[arrayIndex] = null; commitArrayIndex(OBJECTS, EMPTY, originalMarker); return result; }