|
Threads Pool - C Language
|
Vai al codice sorgente di questo file.
Funzioni | |
| void * | test (void *arg) |
| int | main (int argc, char *argv[]) |
This program is free software; you can redistribuite it and/or modify it under the terms of the GNU/General Pubblic License as published the Free software Foundation; either version 2 of the License, or (at your opinion) any later version.
Definizione nel file main.c.
| void* test | ( | void * | arg | ) |
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
main
Definizione alla linea 26 del file main.c.
{
int i=0;
th_pool * pool = NULL;
sigset_t set;
/* Questa maschera ignora tutti i segnali */
if (sigfillset(&set) == -1){
sys_err(__FILE__,__LINE__,"Main: error sigfillset",errno);
exit(EXIT_FAILURE);
}
/* Inizializzo un pool di thread di dimensione 5 e
* con un numero massimo di job in attesa nella coda di 10 */
if (!(pool = poolInit(5, 10, &set))){
exit(EXIT_FAILURE);
}
/* Creo dei job fittizzi da fare eseguire al pool */
for (i=0; i<20; i++){
while (poolDispatcher(pool, test, NULL)==-5){
sleep (1);
}
}
/* Arresto il pool di threads e libero le risorse */
poolDestroy(pool);
return 0;
}