开发者

PThreads: Read/Write Lock: How to check if thread holds the write lock?

I am implementing a wrapper around pthread_rwlock_t for iphone dev. Docs say that acquiring a read lock after acquiring a write lock is undefined. Does POSIX allow me to query whether I already have the write lock? Or, what is the best way of preventing this situation from happening?

开发者_如何转开发

Thanks!


Your wrapper should keep track of whether it already has the write lock held in that thread. You can do this in a number of ways, but looking at how popular libraries ilke boost or ACE do it would probably help.

You should consider using one of those existing libraries and skip the worries and effort of re-implementing what has probably been done before.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜