source: binary-improvements/7dtd-server-fixes/src/BlockingQueue.cs@ 183

Last change on this file since 183 was 182, checked in by alloc, 10 years ago

fixes

File size: 449 bytes
RevLine 
[182]1using System;
2using System.Collections.Generic;
3using System.Threading;
4
5namespace AllocsFixes
6{
7 public class BlockingQueue<T>
8 {
9 private Queue<T> queue = new Queue<T> ();
10
11 public void Enqueue (T item)
12 {
13 lock (queue) {
14 queue.Enqueue (item);
15 Monitor.PulseAll (queue);
16 }
17 }
18
19 public T Dequeue ()
20 {
21 lock (queue) {
22 while (queue.Count == 0) {
23 Monitor.Wait (queue);
24 }
25 return queue.Dequeue ();
26 }
27 }
28
29
30 }
31}
32
Note: See TracBrowser for help on using the repository browser.