Aaron: I just ran into this. I found that one can workaround this by using thread local storage. Create a wrapper around the rwlock that increments a thread local key:
@interface ReadWriteLock : NSObject {
pthread_key_t readKey;
pthread_key_t writeKey;
pthread_rwlock_t rwLock;
}
-(void)lockRead;
-(void)unlockRead;
-(void)lockWrite;
-(void)unlockWrite;
@end
Then increment the readKey using pthread_setspecific when you call lockRead, decrement it when you call unlockRead, only rd_lock when the key goes from 0 to 1 and only rw_unlock when the key goes from 1 to 0. Copy this for the writeLock logic.
Since the pthread_setspecific and pthread_getspecific are thread-local, you don't need to lock around access to these. Make sure to call the appropriate pthread creation / initialization functions in init, and make sure to dispose of all of the pthread_* members in dealloc.
Unfortunately I can't give you the full source to my solution, but the above method works ( I've tested it heavily ).