문제

threads.h supports only dynamic mutex initialization with mtx_init().

Aparently there isn't any info on the internet regarding threads.h apart from: http://en.cppreference.com/w/c/thread.( I would really like to know if there is something more)

Does anyone know how is struct mtx_t in threads.h implemented? I would like to init the mutex statically like in pthreads ( PTHREAD_MUTEX_INITIALIZER ), to avoid calling initialization function every time at the start of the program.

도움이 되었습니까?

해결책

There is no ability of the C11 threads.h to initialize a mutex without calling mtx_init()

threads.h is implemented differently on different platforms - so knowing the implementation detail of how a mtx_t actually look like would't be of much use, you'd be just as well off using the native thread api if it exists, such as pthreads which does provide this ability.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top