-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththreadPool.h
34 lines (16 loc) · 804 Bytes
/
threadPool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <bits/stdc++.h>
#ifndef INC_THREADPOOL_H
#define INC_THREADPOOL_H
#define MAX_THREADS 100
typedef void* threadpool;
// "dispatch_fn" declares a typed function pointer.
// A variable of type "dispatch_fn" points to a function with the following signature:
// void dispatch_function(void *arg);
typedef void (* dispatch_fn)(void*);
//create a given no of threads return a threadpool , else return NULL
threadpool create_threadpool(int num_threads_in_pool);
//takes a threadpool as well as function pointer which to call and a (void*)arg to pass it to the function
void dispatch(threadpool from_me,dispatch_fn dispatch_to_here,void* arg);
//this will cause all threads to destroy and memory will be cleaned up after that.
void destroy_threadpool(threadpool destroyme);
#endif