Up

EOMultiReaderLock class documentation

Authors

Generated by ayers

Software documentation for the EOMultiReaderLock class

EOMultiReaderLock : NSObject

Declared in:
EOControl/EOMultiReaderLock.h
WARNING !!! This class is in the middle of its initial experimental implementation Do not use it yet! But if you'd like to help implementing, please feel free. EOMultiReaderLock is a recursive lock which allows multiple threads to hold a lock for reading but only one thread to hold a lock for writing and only when all reading locks have been relinquished. Once thread requests for a lock to write further requests for a read lock are blocked until the write lock has been granted and relinquished again. But this only holds true if the thread requesting the reading lock does not already hold a reading lock in which case it is granted as it is assumed that this thread needs to continue to release the previously acquired lock or locks.

Instance Variables

Method summary

lockForReading 

- (void) lockForReading;

Blocks until a lock for reading is obtained.

If the thread already holds this lock for reading or writing the method returns immediatly. All successful locks must be paired with corresponding unlocks.


lockForWriting 

- (void) lockForWriting;

Blocks until a lock for writing is obtained.

If the thread already holds this lock for reading or writing the method returns immediatly. All successful locks must be paired with corresponding unlocks.


retrieveReaderLocks 

- (void) retrieveReaderLocks;

Reenables the current registred locks.

This method blocks as long as a writer lock is held by another thread.


suspendReaderLocks 

- (void) suspendReaderLocks;

Disables the currently registered reader locks.

Subsequent calls may increment the count for it's thread but the lock is not reactivated.


tryLockForReading 

- (BOOL) tryLockForReading;

Tries to obtain a lock for reading. Returns NO upon failure.

If the thread already holds this lock for reading or writing the method returns true. All successful locks must be paired with corresponding unlocks.


tryLockForWriting 

- (BOOL) tryLockForWriting;

Tries to obtain a lock for writing. Returns NO upon failure.

If the thread already holds this lock for reading or writing the method returns true. All successful locks must be paired with corresponding unlocks.


unlockForReading 

- (void) unlockForReading;

Relinquishes obtained a previously obtained lock for reading.

If the thread already holds this lock for reading or writing the method returns immediatly. All successful locks must be paired with corresponding unlocks.


unlockForWriting 

- (void) unlockForWriting;

Relinquishes obtained a previously obtained lock for writing.

If the thread already holds this lock for reading or writing the method returns immediatly. All successful locks must be paired with corresponding unlocks.




Instance Variables for EOMultiReaderLock Class

_mutex

@protected NSConditionLock* _mutex;
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_readerFinishedCondition

@protected int _readerFinishedCondition;
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_readerThreads

@protected NSMapTable* _readerThreads;
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_writerFinishedCondition

@protected int _writerFinishedCondition;
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_writerLockCount

@protected unsigned int _writerLockCount;
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_writerLockThread

@protected volatile NSThread* _writerLockThread;
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.





Up