{"id":24557609,"url":"https://github.com/yortw/poolsharp","last_synced_at":"2025-04-18T20:30:13.367Z","repository":{"id":70831121,"uuid":"56903238","full_name":"Yortw/PoolSharp","owner":"Yortw","description":"PoolSharp is a simple, light weight, thread safe object pool.","archived":false,"fork":false,"pushed_at":"2023-11-23T21:49:13.000Z","size":2163,"stargazers_count":24,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T19:03:26.919Z","etag":null,"topics":["c-sharp","object-pool","pool","pool-policies"],"latest_commit_sha":null,"homepage":"http://yortw.github.io/PoolSharp/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yortw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-23T06:01:38.000Z","updated_at":"2024-08-02T20:12:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"008fa876-cb7e-409c-884c-6923bd9d2398","html_url":"https://github.com/Yortw/PoolSharp","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yortw%2FPoolSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yortw%2FPoolSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yortw%2FPoolSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yortw%2FPoolSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yortw","download_url":"https://codeload.github.com/Yortw/PoolSharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249543296,"owners_count":21288703,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","object-pool","pool","pool-policies"],"created_at":"2025-01-23T05:18:20.024Z","updated_at":"2025-04-18T20:30:13.361Z","avatar_url":"https://github.com/Yortw.png","language":"C#","readme":"# PoolSharp\n\n## What is PoolSharp ?\nPoolSharp is a simple, light weight, thread safe object pool.\n\nIt also supports pooling of disposable types, managing the life time of pooled objects and performing early dispose when possible.\nPool implementations implement a simple common interface, so they can be mocked or replaced with alternatives.\n\n[![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/Yortw/PoolSharp/blob/master/LICENSE.md) \n\n## Supported Platforms\nCurrently;\n\n* .Net Framework 4.0+\n* Xamarin.iOS\n* Xamarin.Android\n* WinRT (Windows Store Apps 8.1)\n* UWP 10+ (Windows 10 Universal Programs)\n\n## Build Status\n[![Build status](https://ci.appveyor.com/api/projects/status/88t4uo6hvxfiqbe0?svg=true)](https://ci.appveyor.com/project/Yortw/poolsharp)\n\n## How do I use PoolSharp?\n*We got your samples right here*\n\nInstall the Nuget package like this;\n\n```powershell\n    PM\u003e Install-Package PoolSharp\n```\n\n[![NuGet Badge](https://buildstats.info/nuget/PoolSharp)](https://www.nuget.org/packages/PoolSharp/)\n\nOr reference the PoolSharp.dll assembly that matches your app's platform.\n\n### Creating a Pool\nCreate a PoolPolicy\u003cT\u003e instance to configure options and behaviour for the pool, T is the type of item being pooled.\nCreate a new Pool\u003cT\u003e instance passing the pool policy you created. Pool policies can be re-used across pools so long as the assigned Function and Action delegates are thread-safe.\n\n```C#\n\n    using PoolSharp;\n    // Define a policy. This policy;\n    //  Is for a StringBuilder pool.\n    //  Synchronously resets the StringBuilder state when the item is returned to the pool.\n    //  Pools at most 10 instances\n\n    var policy = new PoolPolicy\u003cSystem.Text.StringBuilder\u003e()\n    {\n    \tFactory = (poolInstance) =\u003e new System.Text.StringBuilder(),\n    \tInitializationPolicy = PooledItemInitialization.Return,\n    \tMaximumPoolSize = 10,\n    \tReinitializeObject = (sb) =\u003e sb.Clear()\n    };\n    \n```\n\n### Using a Pool\nUse the Take method to retrieve an instance from the pool. Use the Add method to return an instance to the pool so it can be re-used.\n\n```C#\n    //Retrieve an instance from the pool\n    var stringbuilder = pool.Take();\n \n    //Do something with the stringbuilder   \n    \n    //Return the string builder to the pool\n    pool.Add(stringbuilder);    \n```\n\n#### Using a Pool with Auto-Return Semantics\nInstead of creating a pool for your specific type, create the pool for PooledObject\u003cT\u003e where T is the type you actually want.\nThen you can use auto-return like this;\n\n```C#\n    //Retrieve an instance from the pool\n    using (var pooledItem pool.Take())\n    {\n        //pooledItem.Value is the object you actually want.\n        //If the pool is for tyhe type PooledObject\u003cSystem.Text.StringBuilder\u003e then\n        //you can access the string builder instance like this;\n        pooledItem.Value.Append(\"Some text to add to the builder\");\n        \n    } // The item will automatically be returned to the pool here.\n```\n\n## Contributing\nContributing is encouraged! Please submit pull requests, open issues etc. However, to ensure we end up with a good result and to make my life a little easier, could I please request that;\n\n* All changes be made in a feature branch, not in master, and please don't submit PR's directly against master.\n* Make sure any PR contains (well named) new and/or updated unit tests to prove the new feature or bug fix. Failing this, please include enough sample data/problem description that I can write the tests myself.\n  \nAlso, not required, but would be really great if;\n\n* You could use tabs instead of spaces (and not argue about it).\n* You could write the code in a similar style as what already exists. I'm not OCD about this so some deviation is fine, we all have different styles and I'm not suggesting mine is 'right', but it helps everybody \nundertand and maintain the code base when it is at least mostly uniform.\n\nThanks! I look forward to merging your awesomesauce.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyortw%2Fpoolsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyortw%2Fpoolsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyortw%2Fpoolsharp/lists"}