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
- Host: GitHub
- URL: https://github.com/ziyasal-archive/obj-pool
- Owner: ziyasal-archive
- License: mit
- Created: 2017-02-06T16:56:03.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-03T08:34:59.000Z (almost 9 years ago)
- Last Synced: 2025-03-20T05:57:36.305Z (about 1 year ago)
- Topics: design-pattern, object-pool
- Language: C#
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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();
}
}
```