All Projects → akkaze → Threadpool

akkaze / Threadpool

Licence: mit
a dynamic threadpool

Programming Languages

cpp
1120 projects

Labels

Projects that are alternatives of or similar to Threadpool

Java Study
java-study 是本人学习Java过程中记录的一些代码!从Java基础的数据类型、jdk1.8的Lambda、Stream和日期的使用、 IO流、数据集合、多线程使用、并发编程、23种设计模式示例代码、常用的工具类, 以及一些常用框架,netty、mina、springboot、kafka、storm、zookeeper、redis、elasticsearch、hbase、hive等等。
Stars: ✭ 571 (+1684.38%)
Mutual labels:  thread
Historyinthreads
Firefox addon: Show browsing history in threads. Search keywords the same way as in Firefox History.
Stars: ✭ 5 (-84.37%)
Mutual labels:  thread
Mruby Actor
A actor library for distributed mruby
Stars: ✭ 11 (-65.62%)
Mutual labels:  thread
Yappi
Yet Another Python Profiler, but this time thread&coroutine&greenlet aware.
Stars: ✭ 595 (+1759.38%)
Mutual labels:  thread
Interlace
Easily turn single threaded command line applications into a fast, multi-threaded application with CIDR and glob support.
Stars: ✭ 760 (+2275%)
Mutual labels:  thread
Oeasypool
c++11 thread pool
Stars: ✭ 18 (-43.75%)
Mutual labels:  thread
Javatutorial
Java教程,包括多线程,泛型,反射,IO,容器类,注解
Stars: ✭ 552 (+1625%)
Mutual labels:  thread
Thread Loader
Runs the following loaders in a worker pool
Stars: ✭ 945 (+2853.13%)
Mutual labels:  thread
Threadandjuc
⭐⭐⭐⭐高并发-高可靠-高性能three-high-import导入系统-高并发多线程进阶
Stars: ✭ 807 (+2421.88%)
Mutual labels:  thread
Atmsimulator
Used the notion of threads and parallelism to make a ATM Simulator.
Stars: ✭ 11 (-65.62%)
Mutual labels:  thread
Android Startup
🔥The Android Startup library provides a straightforward, performant way to initialize components at the application startup. Both library developers and app developers can use Android Startup to streamline startup sequences and explicitly set the order of initialization.
Stars: ✭ 635 (+1884.38%)
Mutual labels:  thread
Raftlib
The RaftLib C++ library, streaming/dataflow concurrency via C++ iostream-like operators
Stars: ✭ 717 (+2140.63%)
Mutual labels:  thread
Taskmanager
A simple、 light(only two file)、fast 、powerful 、easy to use 、easy to extend 、 Android Library To Manager your AsyncTask/Thread/CallBack Jobqueue ! 一个超级简单,易用,轻量级,快速的异步任务管理器,类似于AsyncTask,但是比AsyncTask更好用,更易控制,从此不再写Thread ! ^_^
Stars: ✭ 25 (-21.87%)
Mutual labels:  thread
Grain
grain是一个极简的、组件式的RPC框架,灵活且适合渐进学习,可与任何框架整合。同时包含(系统通用多线程模型与消息通讯 || 多对多关系的分布式锁 || 基于Servlet的HTTP框架 || 基于系统通用多线程模型的Websocket框架 || 支持行级锁的多线程锁 )等组件,按需选择组件,不绑架开发者。
Stars: ✭ 577 (+1703.13%)
Mutual labels:  thread
Promise
Promise-在Java中以同步的方式异步编程
Stars: ✭ 20 (-37.5%)
Mutual labels:  thread
Concurrent Programming
🌵《实战java高并发程序设计》源码整理
Stars: ✭ 562 (+1656.25%)
Mutual labels:  thread
Mt
tlock, RWMUTEX, Collab, USM, RSem and other C++ templates for Windows to provide read/write mutex locks, various multithreading tools, collaboration, differential updates and more
Stars: ✭ 18 (-43.75%)
Mutual labels:  thread
Autocrawler
Google, Naver multiprocess image web crawler (Selenium)
Stars: ✭ 957 (+2890.63%)
Mutual labels:  thread
Openshift Psap
Example roles and yaml files for performance-sensitive applications running on OpenShift
Stars: ✭ 20 (-37.5%)
Mutual labels:  thread
Swifteventbus
A publish/subscribe EventBus optimized for iOS
Stars: ✭ 937 (+2828.13%)
Mutual labels:  thread

ThreadPool

轻量级的 C++11 线程池
Build Status

版权

Public Domain。

您可以放心的在您的项目里面使用,修改代码,不需要考虑任何额外的限制,如果我没有给出正确的版权,请联系我。

概览

ThreadPool 是一个动态的线程池。它能在运行时动态的修改worker的数量。同时也能在运行时等待所有任务结束并重新开始。

构建

请使用支持C++11的编译器,然后安装cmake。

在源代码目录下面新建build文件夹,然后进入build目录,运行cmake .. && make

您将看到basic事例,直接运行即可

使用

使用AddTask接口来将新的任务放置到线程池里进行计算,使用AddWorkers来增加工作线程的数量,使用WaitAll来等待当前任务队列里面所有任务执行完成。一个例子如下,

#include <iostream>
#include "threadpool.h"

int sleep_ms = 1000;
int main() {
    auto f =  { std::cout << "foo\n"; };
    auto g =  { std::cout << "goo\n"; };
    auto h =  { std::cout << "hoo\n"; };
    auto j =  { std::cout << "joo\n"; };

	ThreadPool pool(4);
	for (int i = 0; i < 20; i++) {
    	if (i == 5) {
        	pool.AddWorkers(2);
    	}
    	pool.AddTask(f);
	}
	pool.WaitAll();
	std::cout << "===============\n";
	for (int i = 0; i < 5; i++) {
    	pool.AddTask(g);
    	pool.AddTask(h);
	}
	pool.WaitAll();
	std::cout << "===============\n";
	for (int i = 0; i < 5; i++) {
    	pool.AddTask(j);
	}
}
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].