file
Condvar.hCnxCondvar
provides a higher-level condition variable type similar to that provided in C++'s <condition_variable>
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Classes
- struct CnxCondvar
CnxCondvar
provides a higher-level condition variable type, directly comparable to C++'sstd::condition_variable
, that helps to make writing efficient multi-threaded code simpler and easier.
Enums
- enum CnxCondvarStatus { CnxCondvarNoTimeout = 0, CnxCondvarTimeout }
- Used to communicate the timeout status for
cnx_condvar_wait_for
andcnx_condvar_wait_until
. If a timeout occurs during either of these functions, thenCnxCondvarTimeout
will be returned. OtherwiseCnxCondvarTimeout
will be returned.
Functions
- CnxCondvar cnx_condvar_new(void)
- Creates a new
CnxCondvar
- void cnx_condvar_wait(CnxCondvar*restrict condvar, struct CnxUniqueLock*restrict lock)
- Immediately unlocks
lock
and waits on the givenCnxCondvar
,condvar
until it has been notified by another thread.lock
will be automatically relocked before this function returns. - CnxCondvarStatus cnx_condvar_wait_for(CnxCondvar*restrict condvar, struct CnxUniqueLock*restrict lock, CnxDuration duration)
- Immediately unlocks
lock
and waits on the givenCnxCondvar
,condvar
until it has been notified by another thread, or the amount of time specified byduration
has passed.lock
will be automatically relocked before this function returns. - CnxCondvarStatus cnx_condvar_wait_until(CnxCondvar*restrict condvar, struct CnxUniqueLock*restrict lock, CnxTimePoint stop_point)
- Immediately unlocks
lock
and waits on the givenCnxCondvar
,condvar
until it has been notified by another thread, or point in time specified bystop_point
has occurred.lock
will be automatically relocked before this function returns. - void cnx_condvar_notify_one(CnxCondvar*restrict condvar)
- Notifies exactly one thread waiting on the given
CnxCondvar
to stop waiting and continue execution. - void cnx_condvar_notify_all(CnxCondvar*restrict condvar)
- Notifies all threads waiting on the given
CnxCondvar
to stop waiting and continue execution. - void cnx_condvar_free(CnxCondvar*restrict condvar)
- Destroys the given
CnxCondvar
, freeing any associated resources.