mirror of
https://github.com/Pithikos/C-Thread-Pool
synced 2024-11-24 22:39:56 +03:00
Refactored tests
This commit is contained in:
parent
f269de73f8
commit
42e7937bca
@ -6,7 +6,7 @@
|
||||
#include <time.h>
|
||||
|
||||
/* This showcasts this issue: https://sourceware.org/ml/glibc-bugs/2007-04/msg00036.html */
|
||||
/* Alsoe here: http://stackoverflow.com/questions/27803819/pthreads-leak-memory-even-if-used-correctly/27804629 */
|
||||
/* Also here: http://stackoverflow.com/questions/27803819/pthreads-leak-memory-even-if-used-correctly/27804629 */
|
||||
|
||||
volatile int threads_keepalive = 1;
|
||||
|
||||
@ -14,7 +14,6 @@ void* thread_do(void *arg){
|
||||
while(threads_keepalive)
|
||||
sleep(1);
|
||||
pthread_exit(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
int main(void){
|
||||
|
@ -60,5 +60,6 @@ test_thread_free 1
|
||||
test_thread_free 20
|
||||
test_thread_free_multi 4 20
|
||||
test_thread_free_multi 3 1000
|
||||
test_thread_free_multi 100 100
|
||||
|
||||
echo "No memory leaks"
|
||||
|
@ -22,18 +22,17 @@ int main(int argc, char *argv[]){
|
||||
puts("This testfile needs excactly two arguments");
|
||||
exit(1);
|
||||
}
|
||||
int jobs = strtol(argv[1], &p, 10);
|
||||
int threads = strtol(argv[2], &p, 10);
|
||||
int num_jobs = strtol(argv[1], &p, 10);
|
||||
int num_threads = strtol(argv[2], &p, 10);
|
||||
|
||||
thpool_t* thpool;
|
||||
thpool = thpool_init(threads);
|
||||
thpool threadpool = thpool_init(num_threads);
|
||||
|
||||
int n;
|
||||
for (n=0; n<jobs; n++){
|
||||
thpool_add_work(thpool, (void*)increment, NULL);
|
||||
for (n=0; n<num_jobs; n++){
|
||||
thpool_add_work(threadpool, (void*)increment, NULL);
|
||||
}
|
||||
|
||||
thpool_wait(thpool);
|
||||
thpool_wait(threadpool);
|
||||
|
||||
printf("%d\n", sum);
|
||||
|
||||
|
@ -14,9 +14,8 @@ int main(int argc, char *argv[]){
|
||||
}
|
||||
int threads = strtol(argv[1], &p, 10);
|
||||
|
||||
thpool_t* thpool;
|
||||
thpool = thpool_init(threads);
|
||||
thpool_destroy(thpool);
|
||||
thpool threadpool = thpool_init(threads);
|
||||
thpool_destroy(threadpool);
|
||||
|
||||
sleep(1); // Sometimes main exits before thpool_destroy finished 100%
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user