{"id":27953433,"url":"https://github.com/zjzmisaka/powerthreadpool","last_synced_at":"2026-01-08T11:15:29.497Z","repository":{"id":190681180,"uuid":"682919984","full_name":"ZjzMisaka/PowerThreadPool","owner":"ZjzMisaka","description":"A comprehensive and efficient lock-free thread pool with granular work control, flexible concurrency, and robust error handling, alongside an easy-to-use API for diverse work submissions.","archived":false,"fork":false,"pushed_at":"2025-05-16T08:54:31.000Z","size":1128,"stargazers_count":139,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-16T14:04:54.677Z","etag":null,"topics":["async","coroutine","csharp","dotnet","lock-free","lockfree","task","thread","thread-pool","threadpool"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/PowerThreadPool/","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/ZjzMisaka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-08-25T07:07:45.000Z","updated_at":"2025-05-16T07:57:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"faa84dc5-bd59-4507-a8e4-721d3831a5a0","html_url":"https://github.com/ZjzMisaka/PowerThreadPool","commit_stats":null,"previous_names":["zjzmisaka/powerthreadpool"],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZjzMisaka%2FPowerThreadPool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZjzMisaka%2FPowerThreadPool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZjzMisaka%2FPowerThreadPool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZjzMisaka%2FPowerThreadPool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZjzMisaka","download_url":"https://codeload.github.com/ZjzMisaka/PowerThreadPool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544146,"owners_count":22088807,"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":["async","coroutine","csharp","dotnet","lock-free","lockfree","task","thread","thread-pool","threadpool"],"created_at":"2025-05-07T17:10:39.037Z","updated_at":"2026-01-08T11:15:29.486Z","avatar_url":"https://github.com/ZjzMisaka.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PowerThreadPool\n![icon](https://raw.githubusercontent.com/ZjzMisaka/PowerThreadPool/main/icon.png)\n\n![Nuget](https://img.shields.io/nuget/v/PowerThreadPool?style=for-the-badge)\n![Nuget](https://img.shields.io/nuget/dt/PowerThreadPool?style=for-the-badge)\n![GitHub release (with filter)](https://img.shields.io/github/v/release/ZjzMisaka/PowerThreadPool?style=for-the-badge)\n![GitHub Repo stars](https://img.shields.io/github/stars/ZjzMisaka/PowerThreadPool?style=for-the-badge)\n![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/ZjzMisaka/PowerThreadPool/test.yml?style=for-the-badge)\n[![Codecov](https://img.shields.io/codecov/c/github/ZjzMisaka/PowerThreadPool?style=for-the-badge)](https://app.codecov.io/gh/ZjzMisaka/PowerThreadPool)\n[![CodeFactor](https://www.codefactor.io/repository/github/zjzmisaka/powerthreadpool/badge?style=for-the-badge)](https://www.codefactor.io/repository/github/zjzmisaka/powerthreadpool)\n\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\nA comprehensive and efficient low-contention thread pool for easily managing both sync and async workloads. It provides granular work control, flexible concurrency, and robust error handling.  \n\n## Documentation\nAccess the Wiki in [English](https://github.com/ZjzMisaka/PowerThreadPool/wiki) | [中文](https://github.com/ZjzMisaka/PowerThreadPool.zh-CN.Wiki/wiki) | [日本語](https://github.com/ZjzMisaka/PowerThreadPool.ja-JP.Wiki/wiki).  \nVisit the [DeepWiki](https://deepwiki.com/ZjzMisaka/PowerThreadPool) for more information.  \n\n## Pack\n```ps1\npowershell -File build.ps1 -Version {Version}\n```\n\n## Installation\nIf you want to include PowerThreadPool in your project, you can [install it directly from NuGet](https://www.nuget.org/packages/PowerThreadPool/).  \nSupport: Net40+ | Net5.0+ | netstandard2.0+  \n\n## Features\n- [Sync | Async](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Sync-Async)\n- [Pool Control | Work Control](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Work-Control)\n    - [Stop](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Work-Control#pause-resume-stop)\n    - [Pause](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Work-Control#pause-resume-stop)\n    - [Resume](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Work-Control#pause-resume-stop)\n    - [Force Stop](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Work-Control#force-stop)\n    - [Wait](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Work-Control#wait)\n    - [Fetch](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Work-Control#fetch)\n    - [Cancel](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Work-Control#cancel)\n- [Divide And Conquer](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Divide-And-Conquer)\n- [Thread Pool Sizing](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Thread-Pool-Sizing)\n    - [Idle Thread Scheduled Destruction](https://github.com/ZjzMisaka/PowerThreadPool/wiki/DestroyThreadOption)\n    - [Thread Starvation Countermeasures (Long-running Work Support)](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Thread-Pool-Sizing#thread-starvation)\n- [Work Callback | Default Callback](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Callback)\n- [Rejection Policy](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Rejection-Policy)\n- [Parallel Execution](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Parallel-Execution)\n    - [For](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Parallel-Execution#For)\n    - [ForEach](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Parallel-Execution#ForEach)\n    - [Watch](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Parallel-Execution#Watch)\n- [Work Priority | Thread Priority](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Priority)\n- [Error Handling](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Error-Handling)\n    - [Retry](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Retry)\n- [Work Timeout | Cumulative Work Timeout](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Timeout)\n- [Work Dependency](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Work-Dependency)\n- [Work Group](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Work-Group)\n    - [Group Control](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Work-Group#group-control)\n    - [Group Relation](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Group-Relation)\n- [Events](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Events)\n- [Runtime Status](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Runtime-Status)\n- [Running Timer](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Running-Timer)\n- [Queue Type (FIFO | LIFO | Deque | Custom)](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Queue-Type)\n- [Load Balancing](https://en.wikipedia.org/wiki/Work_stealing)\n- [Low-Contention Design](https://en.wikipedia.org/wiki/Non-blocking_algorithm)\n\n## Getting started\n### Out-of-the-box: Run a simple work\nPTP is designed to be out-of-the-box. For simple works, you can get started without any complex configuration.  \n```csharp\nPowerPool powerPool = new PowerPool();\n// Sync\npowerPool.QueueWorkItem(() =\u003e \n{\n    // Do something\n});\n// Async\npowerPool.QueueWorkItemAsync(async () =\u003e\n{\n    // Do something\n    // await ...;\n});\n```\n\n### With callback\n```csharp\nPowerPool powerPool = new PowerPool(new PowerPoolOption() { /* Some options */ });\n// Sync\npowerPool.QueueWorkItem(() =\u003e \n{\n    // Do something\n    return result;\n}, (res) =\u003e \n{\n    // Callback of the work\n});\n// Async\npowerPool.QueueWorkItemAsync(async () =\u003e\n{\n    // Do something\n    // await ...;\n}, (res) =\u003e\n{\n    // Callback of the work\n});\n```\n\n### With option\n```csharp\nPowerPool powerPool = new PowerPool(new PowerPoolOption() { /* Some options */ });\n// Sync\npowerPool.QueueWorkItem(() =\u003e \n{\n    // Do something\n    return result;\n}, new WorkOption()\n{\n    // Some options\n});\n// Async\npowerPool.QueueWorkItemAsync(async () =\u003e\n{\n    // Do something\n    // await ...;\n}, new WorkOption()\n{\n    // Some options\n});\n```\n\n### Reference\n``` csharp\nWorkID QueueWorkItem\u003cT1, ...\u003e(Action\u003cT1, ...\u003e action, T1 param1, ..., *);\nWorkID QueueWorkItem(Action action, *);\nWorkID QueueWorkItem(Action\u003cobject[]\u003e action, object[] param, *);\nWorkID QueueWorkItem\u003cT1, ..., TResult\u003e(Func\u003cT1, ..., TResult\u003e function, T1 param1, ..., *);\nWorkID QueueWorkItem\u003cTResult\u003e(Func\u003cTResult\u003e function, *);\nWorkID QueueWorkItem\u003cTResult\u003e(Func\u003cobject[], TResult\u003e function, object[] param, *);\nWorkID QueueWorkItemAsync(Func\u003cTask\u003e asyncFunc, *);\nWorkID QueueWorkItemAsync\u003cTResult\u003e(Func\u003cTask\u003cTResult\u003e\u003e asyncFunc, *);\nWorkID QueueWorkItemAsync(Func\u003cTask\u003e asyncFunc, out Task task, *);\nWorkID QueueWorkItemAsync\u003cTResult\u003e(Func\u003cTask\u003cTResult\u003e\u003e asyncFunc, out Task\u003cExecuteResult\u003cTResult\u003e\u003e task, *);\n```\n\n#### Asterisk `*`\n1. `WorkOption` | `WorkOption\u003cT\u003e`: The work option to customize the behavior of the work. \n2. `Action\u003cExecuteResult\u003cT\u003e\u003e`: The callback to be invoked when the work is completed. \n\n#### Ellipses `...`\n1. Up to 5 type parameters are supported.\n\n## More\n[Testing And Performance Analysis](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Testing-And-Performance-Analysis) | [Feature Comparison](https://github.com/ZjzMisaka/PowerThreadPool/wiki/Feature-Comparison)  \n**Get involved**: [Join our growing community](https://github.com/ZjzMisaka/PowerThreadPool/discussions/258)  \n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/dlnn\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/22004270?v=4?s=100\" width=\"100px;\" alt=\"一条咸鱼\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003e一条咸鱼\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ZjzMisaka/PowerThreadPool/commits?author=dlnn\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/ZjzMisaka\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/16731853?v=4?s=100\" width=\"100px;\" alt=\"ZjzMisaka\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eZjzMisaka\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ZjzMisaka/PowerThreadPool/commits?author=ZjzMisaka\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#maintenance-ZjzMisaka\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e \u003ca href=\"https://github.com/ZjzMisaka/PowerThreadPool/commits?author=ZjzMisaka\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/r00tee\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/32619657?v=4?s=100\" width=\"100px;\" alt=\"r00tee\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003er00tee\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-r00tee\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/aadog\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/18098725?v=4?s=100\" width=\"100px;\" alt=\"aadog\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eaadog\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ZjzMisaka/PowerThreadPool/issues?q=author%3Aaadog\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/RookieZWH\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/17580767?v=4?s=100\" width=\"100px;\" alt=\"RookieZWH\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eRookieZWH\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#question-RookieZWH\" title=\"Answering Questions\"\u003e💬\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/hebinary\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/86285187?v=4?s=100\" width=\"100px;\" alt=\"hebinary\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ehebinary\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#question-hebinary\" title=\"Answering Questions\"\u003e💬\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://blog.lindexi.com/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/16054566?v=4?s=100\" width=\"100px;\" alt=\"lindexi\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003elindexi\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ZjzMisaka/PowerThreadPool/issues?q=author%3Alindexi\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzjzmisaka%2Fpowerthreadpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzjzmisaka%2Fpowerthreadpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzjzmisaka%2Fpowerthreadpool/lists"}