public void addNewOrUpdateExisting(DataStoreKey key, DataStoreValue value) { lock (this) { data.CreateNewOrUpdateExisting(key, value); } }
public void lockObject(DataStoreKey key, bool locked) { lock (this) { data.SetLockObject(key, locked); } }
public void SetLockObject(DataStoreKey key, bool objectLock) { if (objectExists(key)) { key = getCorrectKey(key); key.isLocked = objectLock; return; } }
public bool objectExists(DataStoreKey key) { key = getCorrectKey(key); if (key != null) { return(true); } return(false); }
public DataStoreKey getCorrectKey(DataStoreKey key) { foreach (DataStoreKey objectkey in dataStore.Keys) { if (objectkey.Equals(key)) { return(objectkey); } } return(null); }
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"); } }
public DataStoreValue getData(DataStoreKey key) { return(data.getObject(key)); }
public bool dataExists(DataStoreKey key) { return(data.objectExists(key)); }