Mutux type
mtx_recursive mtx_plain mtx_timed
Enumerator mtx_plain passed to ::mtx_init to create a mutex object that supports neither timeout nor test and return
mtx_recursive passed to ::mtx_init to create a mutex object that supports recursive locking
mtx_timed passed to ::mtx_init to create a mutex object that supports timeout
In this implementation this feature is always provided.
mtx_normal passed to ::mtx_init to create a mutex object that deadlocks when locked twice
Consider a deadlock as a feature, here. Without this locking a mutex again is just undefined behavior, so anything could happen.
Remarks
This is an extension that comes with POSIX. Don't use it if you want your code to be portable outside POSIX.
mtx_errorcheck passed to ::mtx_init to create a mutex object that returns an error when locked twice
Remarks
This is an extension that comes with POSIX. Don't use it if you want your code to be portable outside POSIX.
mtx_extras used internally
This is meant to accumulate all extra flags that could be distinguished with POSIX mutex. This is not a valid flag to pass to ::mtx_init.
mtx_recursive 同一个线程试图锁两次是允许的, 如果是mtx_normal类型的mutux就不能锁两次。