chsvlib
chsv helper source code

◆ chsv_event_timedwaitfor()

int Chusov::ExecutionControl::chsv_event_timedwaitfor ( chsv_event_t pEvent,
unsigned long  cMilliseconds 
)
noexcept

Blocks the calling thread until either the specified event is signalled or until the specified amount of time elapses.

Parameters
[in]pEventis an identifier of the event created by chsv_event_init.
[in]cMillisecondsis a time interval for which the blocking is performed. After this time, specified in milliseconds, the function will timeout without acquiring the ownership of the event.
Returns
The function returns chsv_thrd_success on success and chsv_thrd_error on failure. In the last case the function also sets the corresponding errno code.

If multiple threads wait for the same auto-reset event to become signalled, only one of them is released because the event is automatically reset. If multiple threads wait are are going to wait for a manual-reset event to be signalled, and the event is set by a call to chsv_event_set, all of them will be released until the event is explicitly reset by the call to chsv_event_reset.

If the event is signalled by chsv_event_pulse, only those threads are affected (obeying the same rule for manual-reset and auto-reset events) that are waiting at the moment of the signal.

The function implements waiting for an amount of time since the time of the call. Absolute time can be specified to a call to the chsv_event_timedwait function.

See also
chsv_event_set;
chsv_event_pulse;
chsv_event_reset;
chsv_event_wait;
chsv_event_timedwait.