#pragma once #include #include #include #ifdef __cplusplus extern "C" { #endif struct rt_barrier; /* Block until count threads have called rt_barrier_wait. The function will * then return true to one of the threads in the group and reset to its initial * state, waiting for another count threads. */ bool rt_barrier_wait(struct rt_barrier *barrier); struct rt_barrier { struct rt_mutex mutex; struct rt_cond cond; unsigned int level, threshold, generation; }; #define RT_BARRIER_INIT(name, count) \ { \ .mutex = RT_MUTEX_INIT(name.mutex), \ .cond = RT_COND_INIT(name.cond), \ .level = 0, \ .threshold = (count), \ .generation = 0, \ } #define RT_BARRIER(name, count) \ struct rt_barrier name = RT_BARRIER_INIT(name, count) #ifdef __cplusplus } #endif