/// <summary> /// Try to set the state to newState if state equals oldState. Return succeess//fail /// </summary> /// <param name="oldState"></param> /// <param name="newState"></param> /// <returns></returns> private bool CasState(ElementState <T> oldState, ElementState <T> newState) { ElementState <T> prevState = Interlocked.CompareExchange <ElementState <T> >(ref state, newState, oldState); return(oldState == prevState); }
public Element(T value, uint key) { this.value = value; this.key = key; state = new ElementState <T>(false, null); }