Skip to content

A comprehensive and efficient lock-free thread pool with granular work control, flexible concurrency, robust error handling, and easy work management for both sync and async workloads.

License

Notifications You must be signed in to change notification settings

ZjzMisaka/PowerThreadPool

Repository files navigation

PowerThreadPool

icon

Nuget Nuget GitHub release (with filter) GitHub Repo stars GitHub Workflow Status (with event) Codecov CodeFactor

All Contributors

A comprehensive and efficient lock-free thread pool with granular work control, flexible concurrency, robust error handling, and easy work management for both sync and async workloads.

Documentation

Access the Wiki in English | 中文 | 日本語.
Visit the DeepWiki for more information.

Pack

powershell -File build.ps1 -Version {Version}

Installation

If you want to include PowerThreadPool in your project, you can install it directly from NuGet.
Support: Net40+ | Net5.0+ | netstandard2.0+

Features

Getting started

Simple example: run a work

PowerPool powerPool = new PowerPool();
powerPool.QueueWorkItem(() => 
{
    // Do something
});

With callback

PowerPool powerPool = new PowerPool(new PowerPoolOption() { /* Some options */ });
powerPool.QueueWorkItem(() => 
{
    // Do something
    return result;
}, (res) => 
{
    // Callback of the work
});

With option

PowerPool powerPool = new PowerPool(new PowerPoolOption() { /* Some options */ });
powerPool.QueueWorkItem(() => 
{
    // Do something
    return result;
}, new WorkOption()
{
    // Some options
});

Reference

string QueueWorkItem<T1, ...>(Action<T1, ...> action, T1 param1, ..., *);
string QueueWorkItem(Action action, *);
string QueueWorkItem(Action<object[]> action, object[] param, *);
string QueueWorkItem<T1, ..., TResult>(Func<T1, ..., TResult> function, T1 param1, ..., *);
string QueueWorkItem<TResult>(Func<TResult> function, *);
string QueueWorkItem<TResult>(Func<object[], TResult> function, object[] param, *);
  • Asterisk (*) denotes an optional parameter, either a WorkOption or a delegate (Action<ExecuteResult<object>> or Action<ExecuteResult<TResult>>), depending on whether the first parameter is an Action or a Func.
  • In places where you see ellipses (...), you can provide up to five generic type parameters.

More

Testing And Performance Analysis | Feature Comparison

Contributors ✨

Thanks goes to these wonderful people (emoji key):

一条咸鱼
一条咸鱼

💻
ZjzMisaka
ZjzMisaka

💻 🚧 📖
r00tee
r00tee

🤔
aadog
aadog

🐛
RookieZWH
RookieZWH

💬
hebinary
hebinary

💬

This project follows the all-contributors specification. Contributions of any kind welcome!

About

A comprehensive and efficient lock-free thread pool with granular work control, flexible concurrency, robust error handling, and easy work management for both sync and async workloads.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages