-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy paththread_pool.h
73 lines (58 loc) · 1.68 KB
/
thread_pool.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* chatterbox Progetto del corso di LSO 2017
*
* Dipartimento di Informatica Università di Pisa
* Docenti: Prencipe, Torquati
*
* Si dichiara che il programma è, in ogni sua parte,
* opera originale dello studente.
*
* Studente: Luca Corbucci
* Matricola: 516450
*
*/
#if !defined(THREAD_POOL_H_)
#define THREAD_POOL_H_
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <ctype.h>
#include <sys/select.h>
typedef struct my_thread{
int id;
pthread_t thread;
} my_thread;
typedef struct my_pool{
int num;
int attivi;
pthread_t *thread;
} my_PoolThread;
typedef struct thread_param_{
int fd_num;
fd_set * set;
} thread_param;
typedef my_PoolThread * poolThread;
/*
@ Parametri: un intero che mi dice il numero di thread nel pool
@ Return: la nuova struttura contenente i nuovi thread se tutto è andato a buon fine.
@ Inizializza un nuovo pool di thread.
*/
poolThread poolCreate(int n);
/*
@ Parametri: Un intero che mi dice il numero di thread nel pool
Il pool di thread in cui vogliamo inizializzare il thread
La funzione da inserire nella Pthread_create
@ Return: la nuova struttura contenente i nuovi thread se tutto è andato a buon fine.
@ Crea i thread presenti all'interno del pool
eseguendo le chiamate pthread_create e assegnando ai thread la
funzione da svolgere
*/
void poolInit(int n, poolThread pool, void *(*extract)(void *), thread_param ** param);
/*
@ Parametri: il pool di thread che vogliamo cancellare
@ Cancella la memoria occupata dalla struttura che contiene il pool di thread
*/
void poolDelete(poolThread thread);
#endif