public void Clear()
 {
     using (m_lock.Acquire())
     {
         m_queue.Clear();
     };
 }
 public void Clear()
 {
     using (m_lock.Acquire())
     {
         m_set.Clear();
     };
 }
示例#3
0
        /// <summary>
        /// Refresh data from render (visible objects, render messages)
        /// </summary>
        public void BeforeUpdate()
        {
            using (m_lock.Acquire())
            {
                m_outputVisibleObjects.RefreshRead();

                // TODO: OP! This is wrong sync, but it's enough for existing output messages (we can get only half of these messages and second half next frame)
                m_outputRenderMessages.Commit();
            }
        }
示例#4
0
 /// <summary>Returns true when new item was allocated</summary>
 public bool AllocateOrCreate(out Droplet droplet)
 {
     using (_activeLock.Acquire())
     {
         var flag = currentUsed < _baseCapacity;
         droplet = flag ? _unused[currentUsed++] : IncreaseQueueSize();
         _active.Add(droplet);
         return(flag);
     }
 }
示例#5
0
 /// <summary>O(1)</summary>
 public bool Add(T item)
 {
     using (_lock.Acquire())
     {
         if (!_hashSet.Add(item))
         {
             return(false);
         }
         _list.Add(item);
         return(true);
     }
 }
示例#6
0
        public StoragePin Pin()
        {
            using (m_pinLock.Acquire())
            {
                if (Closed)
                {
                    return(default(StoragePin));
                }

                m_pinCount++;
                return(new StoragePin(this));
            }
        }
示例#7
0
        public IDisposable Pin()
        {
            using (m_pinLock.Acquire())
            {
                if (Closed)
                {
                    return(null);
                }

                m_pinCount++;
                return(new StoragePin(this));
            }
        }
示例#8
0
        /// <summary>
        /// Returns true when new item was allocated
        /// </summary>
        public bool AllocateOrCreate(out T item)
        {
            bool create = (m_unused.Count == 0);

            if (create)
            {
                item = new T();
            }
            else
            {
                item = m_unused.Dequeue();
            }
            using (m_activeLock.Acquire())
            {
                m_active.Add(item);
            }
            return(create);
        }
 public void Wrap()
 {
     using (m_lock.Acquire())
     {
         if (History.Count >= m_historyLength)
         {
             History.Dequeue();
         }
         History.Enqueue(Current);
         Current = new T();
     }
 }
示例#10
0
 public uint NextId()
 {
     using (m_lock.Acquire())
     {
         if (m_reuseQueue.Count > m_protecionCount && CheckFirstItemTime())
         {
             return(m_reuseQueue.Dequeue().Id);
         }
         else
         {
             return(++m_maxId);
         }
     }
 }
        /// <summary>Returns true when new item was allocated</summary>
        public bool AllocateOrCreate(out T item)
        {
            bool flag = false;

            using (_activeLock.Acquire())
            {
                flag = _unused.Count == 0;
                item = !flag?_unused.Dequeue() : _activator();

                _active.Add(item);
            }
            return(flag);
        }
 public void Clear()
 {
     using (m_setLock.Acquire())
         using (m_changelistLock.Acquire())
         {
             m_hashSet.Clear();
             m_toAdd.Clear();
             m_toRemove.Clear();
         }
 }
示例#13
0
 public void Add(T entity)
 {
     using (m_cacheLock.Acquire())
     {
         if (m_toRemove.Contains(entity))
         {
             m_toRemove.Remove(entity);
         }
         else
         {
             m_toAdd.Add(entity);
         }
     }
 }
 public TValue this[TKey key]
 {
     get
     {
         using (m_lock.Acquire())
         {
             return(m_dictionary[key]);
         }
     }
     set
     {
         using (m_lock.Acquire())
         {
             m_dictionary[key] = value;
         }
     }
 }
示例#15
0
 public void Enqueue(MyRenderMessageBase message)
 {
     using (m_lock.Acquire())
         RenderInput.Add(message);
 }
示例#16
0
 public T this[int index]
 {
     get { using (m_listLock.Acquire()) return(m_list[index]); }
 }