可重入读/写锁定构造? [英] Re-entrant read/write locking construct?

查看:128
本文介绍了可重入读/写锁定构造?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一位经验丰富的.NET程序员,并且在iOS上伸展双腿。 .NET中我最喜欢的多线程构造之一是 ReaderWriterLock 。它允许多个读者或单个作者。我在iOS中真正缺少的一个功能是锁是可重入的。也就是说,读者线程可以多次获取读锁定,只要它们发布相同即可次数。同样,单个编写器线程可以多次获取锁定,只要它以相同的数量释放锁定。

I'm an experienced .NET programmer and stretching my legs with iOS. One of my favorite multi-threading constructs in .NET is the ReaderWriterLock. It allows for multiple readers or a single writer. The one feature that I am really missing in iOS is that the locks are re-entrant. That is, reader threads can acquire the read lock multiple times as long as they release it the same number of times. Likewise, the single writer thread can acquire the lock multiple times as long as it releases the lock by an equivalent number.

我已经查看了iOS框架而没有这些结构似乎提供了相同的支持,包括重新进入。我也查看了pthread库。我找到了rwlock,但它不允许重入。

I've looked into the iOS Framework and none of the constructs appear to offer the same support including the re-entrancy. I also looked into the pthread library. I found rwlock, but it does not allow re-entrancy.

iOS上是否有允许重入读写锁的内容?

Is there anything on iOS that allows for re-entrant read-write locks?

推荐答案

来自iOS 线程编程指南


系统支持使用读写锁仅限POSIX线程。有关如何使用这些锁的详细信息,请参阅 pthread 手册页。

所以我想如果pthreads不支持re-entrancy,答案是否定的。

So I guess if pthreads don't support re-entrancy, the answer is no.

这篇关于可重入读/写锁定构造?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆