Пример #1
0
 public void addNewOrUpdateExisting(DataStoreKey key, DataStoreValue value)
 {
     lock (this)
     {
         data.CreateNewOrUpdateExisting(key, value);
     }
 }
Пример #2
0
 public void lockObject(DataStoreKey key, bool locked)
 {
     lock (this)
     {
         data.SetLockObject(key, locked);
     }
 }
Пример #3
0
 public void SetLockObject(DataStoreKey key, bool objectLock)
 {
     if (objectExists(key))
     {
         key          = getCorrectKey(key);
         key.isLocked = objectLock;
         return;
     }
 }
Пример #4
0
 public bool objectExists(DataStoreKey key)
 {
     key = getCorrectKey(key);
     if (key != null)
     {
         return(true);
     }
     return(false);
 }
Пример #5
0
 public DataStoreKey getCorrectKey(DataStoreKey key)
 {
     foreach (DataStoreKey objectkey in dataStore.Keys)
     {
         if (objectkey.Equals(key))
         {
             return(objectkey);
         }
     }
     return(null);
 }
Пример #6
0
 public void CreateNewOrUpdateExisting(DataStoreKey key, DataStoreValue value)
 {
     if (objectExists(key))
     {
         key            = getCorrectKey(key);
         dataStore[key] = value;
     }
     else
     {
         dataStore.Add(key, value);
     }
 }
Пример #7
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");
            }
        }
Пример #8
0
 public DataStoreValue getData(DataStoreKey key)
 {
     return(data.getObject(key));
 }
Пример #9
0
 public bool dataExists(DataStoreKey key)
 {
     return(data.objectExists(key));
 }