pthread_rwlockattr_getkind_np() 是否只是 returns 使用 pthread_rwlockattr_setkind_np 设置的标志?
Does pthread_rwlockattr_getkind_np() just returns the flag set using pthread_rwlockattr_setkind_np?
我正在使用 pthread rwlock 并尝试更改 rwlock 行为以优先考虑等待的写入器。从 man page 看来,以下代码片段应该足够了。
pthread_rwlock_t rwlock;
pthread_rwlockattr_t attr;
pthread_rwlockattr_init(&attr); //default attributes
pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); //preference for writer
pthread_rwlock_init(&rwLock, &attr); //use that attribute to create new rwlock
那么pthread_rwlockattr_getkind_np()的目的是什么?只是 return 传递给 pthread_rwlockattr_setkind_np() 的标志吗?
What is the purpose of pthread_rwlockattr_getkind_np() then? Is it to just return the flag that was passed to pthread_rwlockattr_setkind_np()?
是,或者通过 pthread_rwlockattr_init()
设置的初始值,视情况而定。
我正在使用 pthread rwlock 并尝试更改 rwlock 行为以优先考虑等待的写入器。从 man page 看来,以下代码片段应该足够了。
pthread_rwlock_t rwlock;
pthread_rwlockattr_t attr;
pthread_rwlockattr_init(&attr); //default attributes
pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); //preference for writer
pthread_rwlock_init(&rwLock, &attr); //use that attribute to create new rwlock
那么pthread_rwlockattr_getkind_np()的目的是什么?只是 return 传递给 pthread_rwlockattr_setkind_np() 的标志吗?
What is the purpose of pthread_rwlockattr_getkind_np() then? Is it to just return the flag that was passed to pthread_rwlockattr_setkind_np()?
是,或者通过 pthread_rwlockattr_init()
设置的初始值,视情况而定。