Up
Authors
- Generated by ayers
-
- 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
- (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.
- (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.
- (void)
retrieveReaderLocks;
Reenables the current registred locks.
This method blocks as long as a
writer lock is held by another thread.
- (void)
suspendReaderLocks;
Disables the currently registered reader locks.
Subsequent calls may increment the count for
it's thread but the lock is not reactivated.
- (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.
- (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.
- (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.
- (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
@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.
@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.
@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.
@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.
@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.
@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