A minimal but powerful thread pool in ANSI C. Contribute to Pithikos/C-Thread-Pool development by creating an account on GitHub.
A minimal but powerful thread pool in ANSI C. Contribute to Pithikos/C-Thread-Pool development by creating an account on GitHub.
Pithikos/C-Thread-Pool: A minimal but powerful thread pool in ANSI C (github.com) 以上是一个比较精简的c语言版线程池,简单易用。使用方法: Include the header in your source file: #include "thpool.h" Create a thread pool with number of threads you want: threadpool thpool = thpool_init(...
$gccexample.cthpool.c-DTHPOOL_DEBUG-pthread-oexample$./exampleMakingthreadpoolwith4threadsTHPOOL_DEBUG:Createdthread0inpoolTHPOOL_DEBUG:Createdthread1inpoolTHPOOL_DEBUG:Createdthread2inpoolTHPOOL_DEBUG:Createdthread3inpoolAdding10taskstothreadpoolThread#1509455616 working on 0Thread#1509455616 working on 4...
https://github.com/Pithikos/C-Thread-Poolgithub.com/Pithikos/C-Thread-Pool API分析 这个项目使用C语言实现了最为简单的线程池技术,初学者也可以通过这个项目快速理解并使用到自己的线程池,下面是这个项目所提供的API,所有API的介绍都在:thpool.h 中 ...
架构根据生产者和消费者模型构建,首先容器池子,一个管理者,进行池子中工人线程的创建和销毁,主线程,工人线程。https://github.com/AI-ARTS/cthreadpool (吐槽:最开始,写完,出现死锁和段错误,可把我郁闷坏了,找了半天不知道哪里错了,最终经过逻辑梳理,发现错误1、线程空间判断空标志和设置的有出入,所以,以后编程需...
* @struct threadpool_task * @brief the work struct * * @var function Pointer to the function that will perform the task. * @var argument Argument to be passed to the function. */ typedef struct { void (*function)(void *); void *argument; ...
https://github.com/Pithikos/C-Thread-Pool 这是一个简单小巧的C语言线程池实现,在 Github 上有 1.1K 的 star,很适合用来学习 Linux 的多线程编程。 另外,里面还涉及到了信号、队列、同步等知识点,代码读起来还是挺过瘾的。 特点: 符合ANCI C and POSIX; 支持暂停/恢复/等待功能; 简洁的 API; 经过严格的...
int threadpool_free(threadpool_t *pool); 释放线程池所申请的内存资源。 线程池使用 编译 参考项目根目录下的 Makefile, 直接用 make 编译。 测试用例 项目提供了三个测试用例(见 threadpool/test/),我们可以以此来学习线程池的用法并测试是否正常...
* @struct threadpool_task * @brief the work struct * * @var function Pointer to the function that will perform the task. * @var argument Argument to be passed to the function. */ typedef struct { void (*function)(void *); void *argument; ...