Beispiel #1
0
 public void addNewOrUpdateExisting(DataStoreKey key, DataStoreValue value)
 {
     lock (this)
     {
         data.CreateNewOrUpdateExisting(key, value);
     }
 }
Beispiel #2
0
 public void CreateNewOrUpdateExisting(DataStoreKey key, DataStoreValue value)
 {
     if (objectExists(key))
     {
         key            = getCorrectKey(key);
         dataStore[key] = value;
     }
     else
     {
         dataStore.Add(key, value);
     }
 }
Beispiel #3
0
        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");
            }
        }