diff options
Diffstat (limited to 'tests/multithreading/threaded_create_surf.c')
| -rw-r--r-- | tests/multithreading/threaded_create_surf.c | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/tests/multithreading/threaded_create_surf.c b/tests/multithreading/threaded_create_surf.c index 9789565..f7e8d80 100644 --- a/tests/multithreading/threaded_create_surf.c +++ b/tests/multithreading/threaded_create_surf.c @@ -3,48 +3,47 @@ #define THREAD_COUNT 16 +static int finishedThreadCount = 0; +static mtx_t *pmutex; -static int finishedThreadCount = 0; -static mtx_t* pmutex; +int create_surfs() { + for (uint32_t i = 0; i < test_size; i++) { + VkvgSurface s = vkvg_surface_create(device, test_width, test_height); + vkvg_surface_destroy(s); + } -int create_surfs () { - for (uint32_t i=0; i<test_size; i++) { - VkvgSurface s = vkvg_surface_create(device, test_width, test_height); - vkvg_surface_destroy (s); - } - - mtx_lock(pmutex); - finishedThreadCount++; - mtx_unlock(pmutex); - return 0; + mtx_lock(pmutex); + finishedThreadCount++; + mtx_unlock(pmutex); + return 0; } -void fixedSizeRects(){ - mtx_t mutex; - pmutex = &mutex; +void fixedSizeRects() { + mtx_t mutex; + pmutex = &mutex; - vkvg_device_set_thread_aware (device, 1); + vkvg_device_set_thread_aware(device, 1); - thrd_t threads[THREAD_COUNT]; + thrd_t threads[THREAD_COUNT]; - finishedThreadCount = 0; - mtx_init (pmutex, mtx_plain); - for (uint32_t i=0; i<THREAD_COUNT; i++) - thrd_create (&threads[i], create_surfs, NULL); + finishedThreadCount = 0; + mtx_init(pmutex, mtx_plain); + for (uint32_t i = 0; i < THREAD_COUNT; i++) + thrd_create(&threads[i], create_surfs, NULL); - const struct timespec ts = {1,0}; - while (finishedThreadCount < THREAD_COUNT) - thrd_sleep(&ts, NULL); + const struct timespec ts = {1, 0}; + while (finishedThreadCount < THREAD_COUNT) + thrd_sleep(&ts, NULL); - mtx_lock(pmutex); - mtx_unlock(pmutex); - mtx_destroy (pmutex); - pmutex = NULL; + mtx_lock(pmutex); + mtx_unlock(pmutex); + mtx_destroy(pmutex); + pmutex = NULL; - vkvg_device_set_thread_aware (device, 0); + vkvg_device_set_thread_aware(device, 0); } int main(int argc, char *argv[]) { - PERFORM_TEST (fixedSizeRects, argc, argv); - return 0; + PERFORM_TEST(fixedSizeRects, argc, argv); + return 0; } |