chsvlib
chsv helper source code

◆ chsv_event_init()

int Chusov::ExecutionControl::chsv_event_init ( chsv_event_t pEvent,
bool  fManualReset,
bool  fInitialState 
)
noexcept

Creates an event object of the specified type.

Parameters
[out]pEventis a pointer to a buffer receiving an identifier of the created event.
[in]fManualResetis a flag defining if the event is to be of a manual-reset type or of an auto-reset type.
[in]fInitialStatespecifies if the event is to be initially in signalled state.
Returns
The function returns chsv_thrd_success on success, chsv_thrd_nomem if there has not been enough memory in the system to honour the request or chsv_thrd_error if any other error occurred. In the second case the function sets errno to ENOMEM. In the last case errno is set to the corresponding error.

The manual-reset event objects require calling the chsv_event_reset over them in order to set their state to nonsignalled. On the contrary the auto-reset events are automatically set to a nonsignalled state when any threads successfully acquires their ownership using chsv_event_wait, chsv_event_timedwait or chsv_event_timedwaitfor functions. On the other hand the auto-reset event can also be explicitly reset by the chsv_event_reset function.

If multiple threads are blocked invoking the wait functions, than all of them can be released if they are waiting for the manual-reset event. But only one of the waiting threads can be released if the event is of auto-reset type.

The function does not correspond to any of the C11 functions but partially corresponds to Win32 CreateEvent function.

See also
chsv_event_destroy;
chsv_event_set;
chsv_event_pulse;
chsv_event_reset.