Beispiel #1
0
 /// <summary>Remove all items from index</summary>
 public void ClearIndex()
 {
     RWLock.GetWriteLock(_lock, _lockTimeout, delegate {
         _index.Clear();
         return(true);
     });
 }
Beispiel #2
0
 private INode GetNode(KeyType key)
 {
     return(RWLock.GetReadLock(_lock, _lockTimeout, delegate {
         WeakReference value;
         return (INode)(_index.TryGetValue(key, out value) ? value.Target : null);
     }));
 }
Beispiel #3
0
            /// <summary>Add new item to index</summary>
            /// <param name="item">item to add</param>
            /// <returns>was item key previously contained in index</returns>
            public bool AddItem(INode item)
            {
                KeyType key = _getKey(item.Value);

                return(RWLock.GetWriteLock(_lock, _lockTimeout, delegate {
                    bool isDup = _index.ContainsKey(key);
                    _index[key] = new WeakReference(item, false);
                    return isDup;
                }));
            }
Beispiel #4
0
 /// <summary>removes all items from index and reloads each item (this gets rid of dead nodes)</summary>
 public int RebuildIndex()
 {
     lock (_owner._lifeSpan)
         return(RWLock.GetWriteLock(_lock, _lockTimeout, delegate {
             _index.Clear();
             foreach (INode item in _owner._lifeSpan)
             {
                 AddItem(item);
             }
             return _index.Count;
         }));
 }