#pragma once #include #include #include /*! \file event.h \brief An event is a simple threading-object that allows a thread to wait for something to happen on another thread. */ #ifdef __cplusplus extern "C" { #endif typedef struct kinc_event { kinc_event_impl_t impl; } kinc_event_t; /// /// Initializes an event-object. /// /// The event to initialize /// When auto-clear is true, the event is automatically reset to an unsignaled state after a successful wait-operation KINC_FUNC void kinc_event_init(kinc_event_t *event, bool auto_clear); /// /// Destroys an event-object. /// /// The event to destroy KINC_FUNC void kinc_event_destroy(kinc_event_t *event); /// /// Signals an event which allows threads which are waiting for the event to continue. /// /// The event to signal KINC_FUNC void kinc_event_signal(kinc_event_t *event); /// /// Waits for an event to be signaled. /// /// The event to wait for KINC_FUNC void kinc_event_wait(kinc_event_t *event); /// /// Waits for an event to be signaled or the provided timeout to run out - whatever happens first. /// /// The event to wait for /// The timeout in seconds after which the function returns if the event hasn't been signaled /// Whether the event has been signaled KINC_FUNC bool kinc_event_try_to_wait(kinc_event_t *event, double timeout); /// /// Resets an event to an unsignaled state. /// /// The event to reset KINC_FUNC void kinc_event_reset(kinc_event_t *event); #ifdef __cplusplus } #endif