diff options
author | Prefetch | 2023-07-18 17:31:21 +0200 |
---|---|---|
committer | Prefetch | 2023-07-18 17:31:21 +0200 |
commit | bdf186e13258abd9c5fb932d84a7ea1e15c7d933 (patch) | |
tree | 060cd19f6cf365e57a261c229edc86efd0be7d99 /tests/test01.c | |
parent | dd36d3b62b2c7e246a9a42236e09180720d6771d (diff) |
This test was basically a duplicate, remove it
Diffstat (limited to 'tests/test01.c')
-rw-r--r-- | tests/test01.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/tests/test01.c b/tests/test01.c index 198dac7..4c7919c 100644 --- a/tests/test01.c +++ b/tests/test01.c @@ -1,9 +1,9 @@ -#include "linen.h" - #include <stdio.h> #include <stdlib.h> -#include <unistd.h> #include <time.h> +#include <unistd.h> + +#include "linen.h" #define NUM_THREADS 10 @@ -26,7 +26,8 @@ void* f(void* arg) { void main() { - printf("\x1B[1mTEST 01: threads print after random delay:\x1B[0m\n"); + printf("\x1B[1mTEST 01: threads print after random delay " + "while getting joined consecutively:\x1B[0m\n"); /* Thread handles and arguments */ linen_thread_t ts[NUM_THREADS]; @@ -47,6 +48,15 @@ void main() { } } - /* Wait for threads to finish */ - usleep(1200000); + /* Wait for each thread to finish in order, and print its argument. + * The first message only prints once thread #0 is done, and so on. */ + for (int i = 0; i < NUM_THREADS; i++) { + useconds_t* pd; + int r = linen_thread_finish(ts[i], (void**)&pd); + if (r) { + printf(" Failed to join thread #%d with error %d\n", i, r); + } else { + printf(" Thread #%d slept for %dms\n", i, *pd / 1000); + } + } } |