All Projects → Fdhvdu → Threadpool

Fdhvdu / Threadpool

Licence: mit
A fastest, exception-safety and pure C++17 thread pool.

Projects that are alternatives of or similar to Threadpool

Webserver
A C++ High Performance Web Server
Stars: ✭ 4,164 (+3903.85%)
Mutual labels:  thread-pool
Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (+397.12%)
Mutual labels:  thread-pool
Marl
A hybrid thread / fiber task scheduler written in C++ 11
Stars: ✭ 1,078 (+936.54%)
Mutual labels:  thread-pool
Rust Threadpool
A very simple thread pool for parallel task execution
Stars: ✭ 374 (+259.62%)
Mutual labels:  thread-pool
Concurrency
Java 并发编程知识梳理以及常见处理模式 features and patterns
Stars: ✭ 495 (+375.96%)
Mutual labels:  thread-pool
Oeasypool
c++11 thread pool
Stars: ✭ 18 (-82.69%)
Mutual labels:  thread-pool
easy-java
整理java技术要点,让java更简单,更容易上手。
Stars: ✭ 23 (-77.88%)
Mutual labels:  thread-pool
Blog
Java Performance
Stars: ✭ 83 (-20.19%)
Mutual labels:  thread-pool
0d1n
Tool for automating customized attacks against web applications. Fully made in C language with pthreads, it has fast performance.
Stars: ✭ 506 (+386.54%)
Mutual labels:  thread-pool
Pysoc.js
😎 Simple gsoc data scraper, search for any keyword and instantly get data about the orgs that match your search criteria, use filters to sort and analyse the data, uses fuzzy-searching to improve user-search experience
Stars: ✭ 35 (-66.35%)
Mutual labels:  thread-pool
Transmittable Thread Local
📌 TransmittableThreadLocal (TTL), the missing Java™ std lib(simple & 0-dependency) for framework/middleware, provide an enhanced InheritableThreadLocal that transmits values between threads even using thread pooling components.
Stars: ✭ 4,678 (+4398.08%)
Mutual labels:  thread-pool
Chat
Java NIO+多线程实现聊天室
Stars: ✭ 454 (+336.54%)
Mutual labels:  thread-pool
Webcpp
用C++开发web服务器框架
Stars: ✭ 23 (-77.88%)
Mutual labels:  thread-pool
Threadpool
based on C++11 , a mini threadpool , accept variable number of parameters 基于C++11的线程池,简洁且可以带任意多的参数
Stars: ✭ 341 (+227.88%)
Mutual labels:  thread-pool
Vos backend
vangav open source - backend; a backend generator (generates more than 90% of the code needed for big scale backend services)
Stars: ✭ 71 (-31.73%)
Mutual labels:  thread-pool
awesome-dotnet-async
A curated list of awesome articles and resources to learning and practicing about async, threading, and channels in .Net platform. 😉
Stars: ✭ 84 (-19.23%)
Mutual labels:  thread-pool
Concurrent Programming
🌵《实战java高并发程序设计》源码整理
Stars: ✭ 562 (+440.38%)
Mutual labels:  thread-pool
Threads.js
🧵 Make web workers & worker threads as simple as a function call.
Stars: ✭ 1,328 (+1176.92%)
Mutual labels:  thread-pool
Memento
Fairly basic redis-like hashmap implementation on top of a epoll TCP server.
Stars: ✭ 74 (-28.85%)
Mutual labels:  thread-pool
Androidutilcode
AndroidUtilCode 🔥 is a powerful & easy to use library for Android. This library encapsulates the functions that commonly used in Android development which have complete demo and unit test. By using it's encapsulated APIs, you can greatly improve the development efficiency. The program mainly consists of two modules which is utilcode, which is commonly used in development, and subutil which is rarely used in development, but the utils can be beneficial to simplify the main module. 🔥
Stars: ✭ 30,239 (+28975.96%)
Mutual labels:  thread-pool

Warnings

Since commit 468129863ec65c0b4ede02e8581bea682351a6d2, I move ThreadPool to C++17. (To use std::apply.)
In addition, the rule of passing parameters to ThreadPool is different.
Unlike before, which uses std::bind, ThreadPool will not copy anything right now.
All of ThreadPool does is forward (no decay).
This means you have to copy arguments by yourself before passing it to ThreadPool.
Below is demonstration,

void test(int &i)
{
	i=10;
}

int main()
{
	int i(0);
	CThreadPool tp;
	tp.join(tp.add(test,i));

	//before commit f66048ed999aa1b50dc956c4a728ff565042d761
	cout<<i<<endl;	//0

	//since commit f66048ed999aa1b50dc956c4a728ff565042d761
	cout<<i<<endl;	//10
}

Contents

Introduction
Class view
Performance comparison
Compiler
How to compile
Compilation errors?
Tutorial
Future work

Introduction

This is a pure (which means it doesn't depend on any platform) and exception-safety C++ threadpool (so far, there is no standard threadpool in C++).
The goal of this project is to provide a fastest, beautiful and easy-to-use C++ threadpool library.

Class view

Two classes

CThreadPool, including the member function
	thread_id    add(Func &&,Args &&...)
	void         add_and_detach(Func &&,Args &&...)
	size_type    empty() const noexcept
	void         join(thread_id)
	void         join_all()
	bool         joinable(thread_id) const
	size_type    size() const noexcept
	void         wait_until_all_usable() const
	
CThreadPool_Ret, including the member function
	thread_id    add(Func &&,Args &&...)
	size_type    empty() const noexcept
	Ret          get(thread_id)
	size_type    size() const noexcept
	bool         valid(thread_id) const
	void         wait(thread_id) const
	void         wait_all() const

Use the CThreadPool_Ret when you want to get the return value of function.
Use the CThreadPool when you don't care the return value of function.
CThreadPool::add_and_detach is faster (very) than CThreadPool_Ret::add.

Performance comparison

progschj/ThreadPool, see Comparison.
Tyler-Hardin/thread_pool, see Comparison.
P.S. About bilash/threadpool, I don't want to test a C-like code.
P.S. nbsdx/ThreadPool cannot pass testing, see README.
P.S. philipphenkel/threadpool cannot pass testing, see README.
P.S. tghosgor/threadpool11 cannot pass testing, see README.
P.S. mtrebi/thread-pool cannot pass testing, see README.
See the directory for more details.

Compiler

Visual Studio 2017 15.5.5
g++ 7.2.1
clang++ 5.0.1

How to compile

You have to download my lib first.
The directory should be look like

├── lib
│   ├── header
│   ├── LICENSE
│   ├── README.md
│   ├── src
│   └── tutorial
└── ThreadPool
    ├── comparison
    ├── header
    ├── LICENSE
    ├── README.md
    ├── src
    └── tutorial

Don't forget to compile lib/src/Scope_guard.cpp.

Compilation errors?

See How to compile or email me

Tutorial

I provide example.cpp and example_ret.cpp to help you understand how to use this powerful thread pool
To use example.cpp:

g++ -std=c++17 tutorial/example.cpp src/* ../lib/src/Scope_guard.cpp

To use example_ret.cpp:

g++ -std=c++17 tutorial/example_ret.cpp src/IThreadPoolItemBase.cpp ../lib/src/Scope_guard.cpp

Future work

add a non-block version of CThreadPool::add
work stealing

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].