Skip to content

Greetlist/base_thread_pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[TOC]

base_thread_pool

How To Use

int main(int argc, char** argv) {
	struct ThreadPool* pool = newThreadPool(5); //argument is the number of threads.
	if (pool == NULL) {
		printf("Create pool error.\n");
		return -1;
	}
	for (int i = 0; i < 20; ++i) {
		//	First Argument is task priority, 
		//	Second argument is callback function,
		//	Third argument is callback function's args.
		struct Task* task = newTask(i, myFucn, NULL);  
		if (task == NULL) {
			printf("New Task Error.\n");
			continue;
		}
		addTaskToThreadPool(pool, task); //Add To Priority Queue,wait to excute.
	}
	while (1) {}
	return 0;
}

About

Simple Thread Pool Implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages