.github/workflows cmake doc/image src .gitattributes .gitignore CMakeLists.txt MyFunction.h README.md tutorial.cpp README CThreadPool 说明文档 一. 简介 CThreadPool是一个跨平台的、无任何三方依赖的、高性能的C++11(含以上版本)版本的线程池,也是CGraph项目中使用的跨平台线程池组件功能的最小集。
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(...
int thpool_add_work(threadpool, void (*function_p)(void*), void* arg_p); 添加工作(function_p)到线程工作队列中,由线程池中的线程进行调用。 void thpool_wait(threadpool); 等待线程池中所有任务执行完成。 void thpool_pause(threadpool); 暂停当前线程池中的所有线程。 void thpool_resume(threadpool...
https://github.com/Pithikos/C-Thread-Pool 这是一个简单小巧的C语言线程池实现,在 Github 上有 1.1K 的 star,很适合用来学习Linux的多线程编程。 另外,里面还涉及到了信号、队列、同步等知识点,代码读起来还是挺过瘾的。 特点: 符合ANCI C and POSIX; ...
架构根据生产者和消费者模型构建,首先容器池子,一个管理者,进行池子中工人线程的创建和销毁,主线程,工人线程。https://github.com/AI-ARTS/cthreadpool (吐槽:最开始,写完,出现死锁和段错误,可把我郁闷坏了,找了半天不知道哪里错了,最终经过逻辑梳理,发现错误1、线程空间判断空标志和设置的有出入,所以,以后编程需...
* @file threadpool.c * @brief Threadpool implementation file */#include <stdlib.h>#include <pthread.h>#include <unistd.h>#include "threadpool.h"typedef enum { immediate_shutdown =1, graceful_shutdown =2} threadpool_shutdown_t;
static void *threadpool_thread(void *threadpool); 线程池每个线程所执行的函数。 int threadpool_free(threadpool_t *pool); 释放线程池所申请的内存资源。 线程池使用 编译 参考项目根目录下的 Makefile, 直接用 make 编译。
} threadpool_shutdown_t; /** * @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 { ...
具体的实现方式可以参考:https://github.com/hadisi1993/TinyThreadPool 进阶:可以动态调整线程数量的线程池(待续)。