/* * (c) Copyright, Real-Time Innovations, 2016-2024. * All rights reserved. * * No duplications, whole or partial, manual or electronic, may be made * without express written permission. Any such copies, or * revisions thereof, must display this notice unaltered. * This code contains trade secrets of Real-Time Innovations, Inc. */ #ifndef osapi_barrier_h #define osapi_barrier_h #include "log/log_common.h" #include "osapi/osapi_log.h" #include "osapi/osapi_dll.h" #include "osapi/osapi_semaphore.h" #ifdef __cplusplus extern "C" { #endif /** @internal \file * \brief Barrier semaphore */ /** @internal \defgroup RTIOsapiBarrierClass RTIOsapiBarrier * \ingroup RTIOsapiModule * \brief OS independent encapsulation of a barrier semaphore/ */ struct RTIOsapiBarrier; /** @internal \ingroup RTIOsapiSemaphoreClass * * @brief Creates a new barrier semaphore. * * @param barrierSize \b In. Size of the barrier. Equivalent to the number of * threads to synchronize. * */ extern RTIOsapiDllExport struct RTIOsapiBarrier *RTIOsapiBarrier_new( RTI_INT32 barrierSize); /** @internal \ingroup RTIOsapiSemaphoreClass * * @brief Deletes a RTIOsapiBarrier. */ extern RTIOsapiDllExport void RTIOsapiBarrier_delete( struct RTIOsapiBarrier *self); /** @internal \ingroup RTIOsapiSemaphoreClass * * @brief Wait for all the threads to arrive to the barrier. * * The operation will block indefinitely until all the expected threads also * call wait on this barrier. After the last the threads arrives, this * operation will unblock as efficiently as the OS provides. */ extern RTIOsapiDllExport RTIOsapiSemaphoreStatus RTIOsapiBarrier_wait(struct RTIOsapiBarrier *self); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* osapi_barrier_h */