예제 #1
0
 public bool ContainsKey(K key)
 {
     using (AutoLock.LockToRead(_lock, _timeout))
     {
         return(_dictionary.ContainsKey(key));
     }
 }
예제 #2
0
 public bool ContainsValue(V value)
 {
     using (AutoLock.LockToRead(_lock, _timeout))
     {
         return(_dictionary.ContainsValue(value));
     }
 }
예제 #3
0
        /// <summary>
        /// Retrieves the next item in the queue without removing the item.
        /// </summary>
        /// <param name="trimWhenEmpty">true to trim the queue size when empty</param>
        /// <returns>T object or default T object when empty</returns>
        public T GetNextItem(bool trimWhenEmpty)
        {
            using (AutoLock.LockToRead(_lock, _timeout))
            {
                if (0 != _queue.Count)
                {
                    return(_queue.Peek( ));
                }
                else
                {
                    if (trimWhenEmpty)
                    {
                        // Release the queue memory (by default, once the queue grows,
                        // it won't release any allocated memory even if it's empty)
                        _queue.TrimExcess( );
                    }
                }
            }

            return(default(T));
        }
예제 #4
0
 public V this [K key]
 {
     get { using (AutoLock.LockToRead(_lock, _timeout)) { return(_dictionary [key]); } }
     set { using (AutoLock.LockToWrite(_lock, _timeout)) { _dictionary [key] = value; } }
 }