private DQueue <int> GenerateTestQueue() { var queue = new DQueue <int>(); queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); queue.Enqueue(4); queue.Enqueue(5); return(queue); }
//[TestMethod] public void TestMethod_Temp1() { DQueue <IntPtr> queue = new DQueue <IntPtr>(1024); int msgCount = 10000; Task.Run(() => { for (int count = 0; count < msgCount; count++) { IntPtr msg = Marshal.AllocHGlobal(256); queue.Enqueue(msg); } }); for (int count = 0; count < msgCount; count++) { IntPtr msg = Marshal.AllocHGlobal(256); queue.Enqueue(msg); } Thread.Sleep(500); Assert.IsTrue(queue.Count == msgCount * 2); }
/// <summary> /// 构造函数 /// </summary> public ByteBufferPool(long blockSize, long maxByteSize) { this._bolckSize = blockSize; _queueFree = new DQueue <ByteBuffer>((int)(maxByteSize / blockSize), 16); }