public void lazySet(T obj, V newValue) { if (obj == null || obj.getClass() != tclass || cclass != null || (newValue != null && vclass != null && vclass != newValue.getClass())) updateCheck(obj, newValue); unsafe.putOrderedObject(obj, offset, newValue); }
public boolean compareAndSet(T obj, V expect, V update) { if (obj == null || obj.getClass() != tclass || cclass != null || (update != null && vclass != null && vclass != update.getClass())) updateCheck(obj, update); return unsafe.compareAndSwapObject(obj, offset, expect, update); }
public boolean weakCompareAndSet(T obj, V expect, V update) { // same implementation as strong form for now if (obj == null || obj.getClass() != tclass || cclass != null || (update != null && vclass != null && vclass != update.getClass())) updateCheck(obj, update); return unsafe.compareAndSwapObject(obj, offset, expect, update); }
public boolean containsValue(final V val) { final byte[] states = this._states; final V[] vals = (V[]) this._values; if (null == val) { int i = vals.length; while (i-- > 0) { if (states[i] == 1 && val == vals[i]) { return true; } } } else { int i = vals.length; while (i-- > 0) { if (states[i] == 1 && (val == vals[i] || val.equals(vals[i]))) { return true; } } } return false; }