static void Main(string[] args) { Console.Write(@"Test Lock-free "); if (testObject == TestObject.Pool) { Console.WriteLine("Pool"); testPool = true; } else if (testObject == TestObject.FastPool) { Console.WriteLine("Fast Pool"); testPool = true; } else if (testObject == TestObject.StackQueue) { Console.WriteLine("Stack & Queue (Not Pool)"); testPool = false; } else throw new NotImplementedException(); Console.WriteLine(@"ThreadPool Test Starting..."); Console.WriteLine(@" All threads: {0}", threads); Console.WriteLine(@" Buffers per thread: {0}", actions); Console.WriteLine(@" Buffer pool size: {0}", poolSize); Console.WriteLine(); if (testPool) { if (testObject == TestObject.Pool) pool = new LockFreePool<Item>(poolSize); if (testObject == TestObject.FastPool) pool = new LockFreeFastPool<Item>(poolSize); } else { array = new LockFreeItem<Item>[poolSize + 1]; for (int i = 1; i < array.Length; i++) array[i].Value = new Item(); queue = new LockFreeQueue<Item>(array, 0, poolSize + 1); stack = new LockFreeStack<Item>(array, -1, -1); } items = new bool[65536]; run = true; for (int i = 0; i < threads; i++) { var thread = new Thread(TestBufferPool); thread.Start(); } Console.WriteLine(@"Started. Press any key to stop..."); Console.ReadKey(true); run = false; while (count > 0) Thread.Sleep(25); }
internal static void Initialize() { EventArgsManager.pool = new LockFreePool <ServerAsyncEventArgs>((int)(BufferManager.MaxMemoryUsage / 2048L)); }
internal static void Initialize() { pool = new LockFreePool<ServerAsyncEventArgs>( (int)(BufferManager.MaxMemoryUsage / ServerAsyncEventArgs.DefaultSize)); }
internal static void Initialize() { pool = new LockFreePool <ServerAsyncEventArgs>( (int)(BufferManager.MaxMemoryUsage / ServerAsyncEventArgs.DefaultSize)); }
static void Main(string[] args) { Console.Write(@"Test Lock-free "); if (testObject == TestObject.Pool) { Console.WriteLine("Pool"); testPool = true; } else if (testObject == TestObject.FastPool) { Console.WriteLine("Fast Pool"); testPool = true; } else if (testObject == TestObject.StackQueue) { Console.WriteLine("Stack & Queue (Not Pool)"); testPool = false; } else { throw new NotImplementedException(); } Console.WriteLine(@"ThreadPool Test Starting..."); Console.WriteLine(@" All threads: {0}", threads); Console.WriteLine(@" Buffers per thread: {0}", actions); Console.WriteLine(@" Buffer pool size: {0}", poolSize); Console.WriteLine(); if (testPool) { if (testObject == TestObject.Pool) { pool = new LockFreePool <Item>(poolSize); } if (testObject == TestObject.FastPool) { pool = new LockFreeFastPool <Item>(poolSize); } } else { array = new LockFreeItem <Item> [poolSize + 1]; for (int i = 1; i < array.Length; i++) { array[i].Value = new Item(); } queue = new LockFreeQueue <Item>(array, 0, poolSize + 1); stack = new LockFreeStack <Item>(array, -1, -1); } items = new bool[65536]; run = true; for (int i = 0; i < threads; i++) { var thread = new Thread(TestBufferPool); thread.Start(); } Console.WriteLine(@"Started. Press any key to stop..."); Console.ReadKey(true); run = false; while (count > 0) { Thread.Sleep(25); } }