예제 #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));
 }