public void Enqueue(T msg) { lock (m_objLock) { m_msgQueue.Enqueue(msg); GotNewMessageEvent.Set(); } }
public void Enqueue(T[] msgs) { lock (m_objLock) { foreach (T nextt in msgs) { m_msgQueue.Enqueue(nextt); } GotNewMessageEvent.Set(); } }
private T PopNextMessage() { T msgret = default(T); lock (m_objLock) { if (m_msgQueue.Count > 0) { msgret = m_msgQueue.Dequeue(); } if (m_msgQueue.Count > 0) /// mo Amessages { GotNewMessageEvent.Set(); /// signal more people } } return(msgret); }
public void EnqueueSorted(T[] msgs, IComparer <T> comparer) { lock (m_objLock) { List <T> listnewsorted = new List <T>(); T[] arrayexisting = m_msgQueue.ToArray(); m_msgQueue.Clear(); listnewsorted.AddRange(arrayexisting); listnewsorted.AddRange(msgs); listnewsorted.Sort(comparer); foreach (T nextt in listnewsorted) { m_msgQueue.Enqueue(nextt); } GotNewMessageEvent.Set(); } }