An open API service indexing awesome lists of open source software.

https://github.com/ziyasal-archive/obj-pool

:skull: object pool implementation
https://github.com/ziyasal-archive/obj-pool

design-pattern object-pool

Last synced: 8 months ago
JSON representation

:skull: object pool implementation

Awesome Lists containing this project

README

          

# obj-pool
simple object pool implementation

```cs
public class Program
{
public static void Main(string[] args)
{
CancellationTokenSource cts = new CancellationTokenSource();

Task.Run(() =>
{
if (Console.ReadKey().KeyChar == 'c' || Console.ReadKey().KeyChar == 'C')
cts.Cancel();
}, cts.Token);

ObjectPool pool = new TestPool();

Parallel.For(0, 1000000, (i, loopState) =>
{
TestClass mc = pool.CheckOut();
Console.CursorLeft = 0;
Console.WriteLine("{0:####.####}", mc.GetValue(i));

pool.CheckIn(mc);
if (cts.Token.IsCancellationRequested)
loopState.Stop();

});

Console.WriteLine("Press the Enter key to exit.");
Console.ReadLine();
cts.Dispose();
}
}

```