public void addNewOrUpdateExisting(DataStoreKey key, DataStoreValue value) { lock (this) { data.CreateNewOrUpdateExisting(key, value); } }
public void CreateNewOrUpdateExisting(DataStoreKey key, DataStoreValue value) { if (objectExists(key)) { key = getCorrectKey(key); dataStore[key] = value; } else { dataStore.Add(key, value); } }
public DataStoreValue getObject(DataStoreKey key) { DataStoreKey keyCorrect = getCorrectKey(key); if (keyCorrect != null) { lock (this) { readQueue.Add(key); while (keyCorrect.isLocked || !readQueue[0].Equals(key)) { Monitor.Wait(this); } DataStoreValue result = dataStore[keyCorrect]; readQueue.RemoveAt(0); Monitor.PulseAll(this); return(result); } } else { throw new Exception("Object does not exist"); } }