mirror of
https://github.com/Pithikos/C-Thread-Pool
synced 2024-11-25 06:49:37 +03:00
Test prettyfy
This commit is contained in:
parent
6363733f8a
commit
17aa5fe9ed
@ -8,7 +8,7 @@ pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
|||||||
int sum=0;
|
int sum=0;
|
||||||
|
|
||||||
|
|
||||||
void add_one() {
|
void increment() {
|
||||||
pthread_mutex_lock(&mutex);
|
pthread_mutex_lock(&mutex);
|
||||||
sum ++;
|
sum ++;
|
||||||
pthread_mutex_unlock(&mutex);
|
pthread_mutex_unlock(&mutex);
|
||||||
@ -25,15 +25,15 @@ int main(int argc, char *argv[]){
|
|||||||
int jobs = strtol(argv[1], &p, 10);
|
int jobs = strtol(argv[1], &p, 10);
|
||||||
int threads = strtol(argv[2], &p, 10);
|
int threads = strtol(argv[2], &p, 10);
|
||||||
|
|
||||||
thpool_t* threadpool;
|
thpool_t* thpool;
|
||||||
threadpool = thpool_init(threads);
|
thpool = thpool_init(threads);
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
for (n=0; n<jobs; n++){
|
for (n=0; n<jobs; n++){
|
||||||
thpool_add_work(threadpool, (void*)add_one, NULL);
|
thpool_add_work(thpool, (void*)increment, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
thpool_wait(threadpool);
|
thpool_wait(thpool);
|
||||||
|
|
||||||
printf("%d\n", sum);
|
printf("%d\n", sum);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user