Muvicado HD
Loading...
Searching...
No Matches
MutLockArray Class Reference

Similar to NSMutableArray, but thread-safe. Internally, uses an NSMutableArray and a rwlock. More...

#include <MutLockArray.h>

Inheritance diagram for MutLockArray:
Collaboration diagram for MutLockArray:

Instance Methods

(id) - initWithCapacity:
 Inits and returns a MutLockArray with a given capacity; the capacity may be 0.
(id) - init
(void) - rdlock
 Establishes a read-lock for the array; multiple read locks may exist simultaneously (if it's not changing, anything can look at the contents of the array). This method does not return until it has been able to get the lock.
(void) - wrlock
 Establishes a write-lock for the array. Only one write-lock may exist at any given time, and all read-locks must be relinquished before the write-lock may be established (if you're going to change the array, nothing else can be changing or observing it).
(void) - unlock
 Unlocks the array.
(NSMutableArray *) - array
 Returns the NSMutableArray with everything in it. This returns the actual array, so be careful- it's possible to do something which ISN'T threadsafe with this...
(NSMutableArray *) - createArrayCopy
 Returns an NSMutableArray which was created by calling "mutableCopy" on my array. Again, it's possible to do something which ISN'T threadsafe by calling this...
(NSMutableArray *) - lockCreateArrayCopy
 Returns an NSMutableArray which was created while a read-lock was established; this is threadsafe.
(void) - addObject:
 Calls "addObject" on my array; not threadsafe.
(void) - lockAddObject:
 Establishes a write-lock, then calls "addObject" on self; threadsafe.
(void) - addObjectsFromArray:
 Calls "addObjectsFromArray" on my array; not threadsafe.
(void) - lockAddObjectsFromArray:
 Establishes a write-lock, then calls "addObjectsFromArray" on self; threadsafe.
(void) - replaceWithObjectsFromArray:
 Calls "addObjectsFromArray" on my array; not threadsafe.
(void) - lockReplaceWithObjectsFromArray:
 Establishes a write-lock, then calls "replaceWithObjectsFromArray" on self; threadsafe.
(void) - insertObject:atIndex:
 Calls "insertObject:atIndex:" on my array; not threadsafe.
(void) - lockInsertObject:atIndex:
 Establishes a write-lock, then calls "insertObject:atIndex:" on self; threadsafe.
(void) - removeAllObjects
 Calls "removeAllObjects" on my array; not threadsafe.
(void) - lockRemoveAllObjects
 Establishes a write-lock, then calls "removeAllObjects" on self; threadsafe.
(id) - firstObject
 Calls "objectAtIndex:0" on my array; not threadsafe.
(id) - lockFirstObject
 Establishes a read-lock, then calls "firstObject" on self; threadsafe.
(void) - removeFirstObject
 Calls "removeObjectAtIndex:0" on my array; not threadsafe.
(void) - lockRemoveFirstObject
 Establishes a write-lock, then calls "removeFirstObject" on self; threadsafe.
(id) - lastObject
 Calls "lastObject" on my array; not threadsafe.
(id) - lockLastObject
 Establishes a read-lock, then calls "lastObject" on self; threadsafe.
(void) - removeLastObject
 Calls "removeLastObject" on my array; not threadsafe.
(void) - lockRemoveLastObject
 Establishes a write-lock, then calls "removeLastObject" on self; threadsafe.
(void) - removeObject:
 Calls "removeObject:" on my array; not threadsafe.
(void) - lockRemoveObject:
 Establishes a write-lock, then calls "removeObject:" on self; threadsafe.
(void) - removeObjectAtIndex:
 Calls "removeObjectAtIndex:" on my array; not threadsafe.
(void) - lockRemoveObjectAtIndex:
 Establishes a write-lock, then calls "removeObjectAtIndex:" on self; threadsafe.
(void) - removeObjectsAtIndexes:
 Calls "removeObjectsAtIndexes:" on my array; not threadsafe.
(void) - lockRemoveObjectsAtIndexes:
 Establishes a write-lock, then calls "removeObjectsAtIndexes:" on self; threadsafe.
(void) - removeObjectsInArray:
 Calls "removeObjectsInArray:" on my array; not threadsafe.
(void) - lockRemoveObjectsInArray:
 Establishes a write-lock, then calls "removeObjectsInArray:" on self; threadsafe.
(void) - removeIdenticalPtrsInArray:
 Calls "removeIdenticalPtrsInArray:" on my array; not threadsafe.
(void) - lockRemoveIdenticalPtrsInArray:
 Establishes a write-lock, then calls "removeIdenticalPtrsInArray:" on self; threadsafe.
(void) - replaceObjectsAtIndexes:withObjects:
 Calls "replaceObjectsAtIndexes:withObjects" on my array; not threadsafe.
(void) - lockReplaceObjectsAtIndexes:withObjects:
(id) - valueForKey:
 Calls "valueForKey:" on my array; not threadsafe.
(id) - lockValueForKey:
 Establishes a read-lock, then calls "valueForKey:" on self; threadsafe.
(BOOL) - containsObject:
 Calls "containsObject:" on my array; not threadsafe.
(BOOL) - lockContainsObject:
 Establishes a read-lock, then calls "containsObject:" on self; threadsafe.
(id) - objectAtIndex:
 Calls "objectAtIndex:" on my array; not threadsafe.
(id) - lockObjectAtIndex:
 Establishes a read-lock, then calls "objectAtIndex:" on self; threadsafe.
(NSArray *) - objectsAtIndexes:
 Calls "objectsAtIndexes:" on my array; not threadsafe.
(NSArray *) - lockObjectsAtIndexes:
 Establishes a read-lock, then calls "objectsAtIndexes:" on self; threadsafe.
(NSUInteger) - indexOfObject:
 Calls "indexOfObject:" on my array; not threadsafe.
(NSUInteger) - lockIndexOfObject:
 Establishes a read-lock, then calls "indexOfObject:" on self; threadsafe.
(BOOL) - containsIdenticalPtr:
 Enumerates through my array- compares the address of each item in the array to the passed pointer. Unlike NSMutableArray, this method does NOT call isEqualTo:, it's just a simple == operator.
(BOOL) - lockContainsIdenticalPtr:
 Establishes a read-lock, then calls "containsIdenticalPtr:" on self; threadsafe.
(int) - indexOfIdenticalPtr:
 Enumerates through my array- compares the address of each item in the array to the passed pointer. Unlike NSMutableArray, this method does NOT call isEqualTo:, it's just a simple == operator.
(int) - lockIndexOfIdenticalPtr:
 Establishes a read-lock, then calls "indexOfIdenticalPtr:" on self; threadsafe.
(void) - removeIdenticalPtr:
 Locates an item in my array by enumerating through it and comparing the address of each item in the array to the passed ptr, and then deletes the matching item from the array; not threadsafe.
(void) - lockRemoveIdenticalPtr:
 Establishes a write-lock, then calls "removeIdenticalPtr:" on self; threadsafe.
(NSArray *) - filteredArrayUsingPredicate:
(NSArray *) - lockFilteredArrayUsingPredicate:
(void) - makeObjectsPerformSelector:
 Calls "makeObjectsPerformSelector:" on my array; not threadsafe.
(void) - lockMakeObjectsPerformSelector:
 Establishes a read-lock, then calls "makeObjectsPerformSelector:" on self; threadsafe.
(void) - makeObjectsPerformSelector:withObject:
 Calls "makeObjectsPerformSelector:withObject:" on my array; not threadsafe.
(void) - lockMakeObjectsPerformSelector:withObject:
 Establishes a read-lock, then calls "makeObjectsPerformSelector:withObject:" on self; threadsafe.
(void) - sortUsingSelector:
 Calls "sortUsingSelector:" on my array; not threadsafe.
(void) - lockSortUsingSelector:
 Establishes a write-lock, then calls "sortUsingSelector:" on self; threadsafe.
(void) - sortUsingDescriptors:
 Calls "sortUsingDescriptors:" on my array; not threadsafe.
(void) - lockSortUsingDescriptors:
 Establishes a write-lock, then calls "sortUsingDescriptors:" on self; threadsafe.
(NSEnumerator *) - objectEnumerator
(NSEnumerator *) - reverseObjectEnumerator
(NSUInteger) - count
(NSUInteger) - lockCount

Class Methods

(id) + arrayWithCapacity:
 Creates and returns an auto-released MutLockArray with a given capacity. The capacity may be 0.

Protected Attributes

NSMutableArray * array
pthread_rwlock_t arrayLock

Detailed Description

Similar to NSMutableArray, but thread-safe. Internally, uses an NSMutableArray and a rwlock.

Definition at line 20 of file MutLockArray.h.

Method Documentation

◆ addObject:

- (void) addObject: (id) o

Calls "addObject" on my array; not threadsafe.

Implemented in MutNRLockArray.

◆ addObjectsFromArray:

- (void) addObjectsFromArray: (id) a

Calls "addObjectsFromArray" on my array; not threadsafe.

Implemented in MutNRLockArray.

◆ array

- (NSMutableArray *) array

Returns the NSMutableArray with everything in it. This returns the actual array, so be careful- it's possible to do something which ISN'T threadsafe with this...

◆ arrayWithCapacity:

+ (id) arrayWithCapacity: (NSUInteger) c

Creates and returns an auto-released MutLockArray with a given capacity. The capacity may be 0.

Implemented in MutNRLockArray.

◆ containsIdenticalPtr:

- (BOOL) containsIdenticalPtr: (id) o

Enumerates through my array- compares the address of each item in the array to the passed pointer. Unlike NSMutableArray, this method does NOT call isEqualTo:, it's just a simple == operator.

Implemented in MutNRLockArray.

◆ containsObject:

- (BOOL) containsObject: (id) o

Calls "containsObject:" on my array; not threadsafe.

Implemented in MutNRLockArray.

◆ count

- (NSUInteger) count
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createArrayCopy

- (NSMutableArray *) createArrayCopy

Returns an NSMutableArray which was created by calling "mutableCopy" on my array. Again, it's possible to do something which ISN'T threadsafe by calling this...

Implemented in MutNRLockArray.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filteredArrayUsingPredicate:

- (NSArray *) filteredArrayUsingPredicate: (NSPredicate *) predicate

◆ firstObject

- (id) firstObject

Calls "objectAtIndex:0" on my array; not threadsafe.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexOfIdenticalPtr:

- (int) indexOfIdenticalPtr: (id) o

Enumerates through my array- compares the address of each item in the array to the passed pointer. Unlike NSMutableArray, this method does NOT call isEqualTo:, it's just a simple == operator.

Implemented in MutNRLockArray.

◆ indexOfObject:

- (NSUInteger) indexOfObject: (id) o

Calls "indexOfObject:" on my array; not threadsafe.

Implemented in MutNRLockArray.

◆ init

- (id) init
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initWithCapacity:

- (id) initWithCapacity: (NSUInteger) c

Inits and returns a MutLockArray with a given capacity; the capacity may be 0.

◆ insertObject:atIndex:

- (void) insertObject: (id) o
atIndex: (NSUInteger) i 

Calls "insertObject:atIndex:" on my array; not threadsafe.

Implemented in MutNRLockArray.

◆ lastObject

- (id) lastObject

Calls "lastObject" on my array; not threadsafe.

Implemented in MutNRLockArray.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lockAddObject:

- (void) lockAddObject: (id) o

Establishes a write-lock, then calls "addObject" on self; threadsafe.

◆ lockAddObjectsFromArray:

- (void) lockAddObjectsFromArray: (id) a

Establishes a write-lock, then calls "addObjectsFromArray" on self; threadsafe.

◆ lockContainsIdenticalPtr:

- (BOOL) lockContainsIdenticalPtr: (id) o

Establishes a read-lock, then calls "containsIdenticalPtr:" on self; threadsafe.

◆ lockContainsObject:

- (BOOL) lockContainsObject: (id) o

Establishes a read-lock, then calls "containsObject:" on self; threadsafe.

◆ lockCount

- (NSUInteger) lockCount
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lockCreateArrayCopy

- (NSMutableArray *) lockCreateArrayCopy

Returns an NSMutableArray which was created while a read-lock was established; this is threadsafe.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lockFilteredArrayUsingPredicate:

- (NSArray *) lockFilteredArrayUsingPredicate: (NSPredicate *) predicate

◆ lockFirstObject

- (id) lockFirstObject

Establishes a read-lock, then calls "firstObject" on self; threadsafe.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lockIndexOfIdenticalPtr:

- (int) lockIndexOfIdenticalPtr: (id) o

Establishes a read-lock, then calls "indexOfIdenticalPtr:" on self; threadsafe.

◆ lockIndexOfObject:

- (NSUInteger) lockIndexOfObject: (id) o

Establishes a read-lock, then calls "indexOfObject:" on self; threadsafe.

◆ lockInsertObject:atIndex:

- (void) lockInsertObject: (id) o
atIndex: (NSUInteger) i 

Establishes a write-lock, then calls "insertObject:atIndex:" on self; threadsafe.

◆ lockLastObject

- (id) lockLastObject

Establishes a read-lock, then calls "lastObject" on self; threadsafe.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lockMakeObjectsPerformSelector:

- (void) lockMakeObjectsPerformSelector: (SEL) s

Establishes a read-lock, then calls "makeObjectsPerformSelector:" on self; threadsafe.

◆ lockMakeObjectsPerformSelector:withObject:

- (void) lockMakeObjectsPerformSelector: (SEL) s
withObject: (id) o 

Establishes a read-lock, then calls "makeObjectsPerformSelector:withObject:" on self; threadsafe.

◆ lockObjectAtIndex:

- (id) lockObjectAtIndex: (NSUInteger) i

Establishes a read-lock, then calls "objectAtIndex:" on self; threadsafe.

◆ lockObjectsAtIndexes:

- (NSArray *) lockObjectsAtIndexes: (NSIndexSet *) indexes

Establishes a read-lock, then calls "objectsAtIndexes:" on self; threadsafe.

◆ lockRemoveAllObjects

- (void) lockRemoveAllObjects

Establishes a write-lock, then calls "removeAllObjects" on self; threadsafe.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lockRemoveFirstObject

- (void) lockRemoveFirstObject

Establishes a write-lock, then calls "removeFirstObject" on self; threadsafe.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lockRemoveIdenticalPtr:

- (void) lockRemoveIdenticalPtr: (id) o

Establishes a write-lock, then calls "removeIdenticalPtr:" on self; threadsafe.

◆ lockRemoveIdenticalPtrsInArray:

- (void) lockRemoveIdenticalPtrsInArray: (NSArray *) a

Establishes a write-lock, then calls "removeIdenticalPtrsInArray:" on self; threadsafe.

◆ lockRemoveLastObject

- (void) lockRemoveLastObject

Establishes a write-lock, then calls "removeLastObject" on self; threadsafe.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lockRemoveObject:

- (void) lockRemoveObject: (id) o

Establishes a write-lock, then calls "removeObject:" on self; threadsafe.

◆ lockRemoveObjectAtIndex:

- (void) lockRemoveObjectAtIndex: (NSUInteger) i

Establishes a write-lock, then calls "removeObjectAtIndex:" on self; threadsafe.

◆ lockRemoveObjectsAtIndexes:

- (void) lockRemoveObjectsAtIndexes: (NSIndexSet *) i

Establishes a write-lock, then calls "removeObjectsAtIndexes:" on self; threadsafe.

◆ lockRemoveObjectsInArray:

- (void) lockRemoveObjectsInArray: (NSArray *) otherArray

Establishes a write-lock, then calls "removeObjectsInArray:" on self; threadsafe.

◆ lockReplaceObjectsAtIndexes:withObjects:

- (void) lockReplaceObjectsAtIndexes: (NSIndexSet *) indexes
withObjects: (NSArray *) objects 

◆ lockReplaceWithObjectsFromArray:

- (void) lockReplaceWithObjectsFromArray: (id) a

Establishes a write-lock, then calls "replaceWithObjectsFromArray" on self; threadsafe.

◆ lockSortUsingDescriptors:

- (void) lockSortUsingDescriptors: (NSArray *) descriptors

Establishes a write-lock, then calls "sortUsingDescriptors:" on self; threadsafe.

◆ lockSortUsingSelector:

- (void) lockSortUsingSelector: (SEL) s

Establishes a write-lock, then calls "sortUsingSelector:" on self; threadsafe.

◆ lockValueForKey:

- (id) lockValueForKey: (NSString *) key

Establishes a read-lock, then calls "valueForKey:" on self; threadsafe.

◆ makeObjectsPerformSelector:

- (void) makeObjectsPerformSelector: (SEL) s

Calls "makeObjectsPerformSelector:" on my array; not threadsafe.

◆ makeObjectsPerformSelector:withObject:

- (void) makeObjectsPerformSelector: (SEL) s
withObject: (id) o 

Calls "makeObjectsPerformSelector:withObject:" on my array; not threadsafe.

◆ objectAtIndex:

- (id) objectAtIndex: (NSUInteger) i

Calls "objectAtIndex:" on my array; not threadsafe.

Implemented in MutNRLockArray.

◆ objectEnumerator

- (NSEnumerator *) objectEnumerator
Here is the call graph for this function:
Here is the caller graph for this function:

◆ objectsAtIndexes:

- (NSArray *) objectsAtIndexes: (NSIndexSet *) indexes

Calls "objectsAtIndexes:" on my array; not threadsafe.

Implemented in MutNRLockArray.

◆ rdlock

- (void) rdlock

Establishes a read-lock for the array; multiple read locks may exist simultaneously (if it's not changing, anything can look at the contents of the array). This method does not return until it has been able to get the lock.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeAllObjects

- (void) removeAllObjects

Calls "removeAllObjects" on my array; not threadsafe.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeFirstObject

- (void) removeFirstObject

Calls "removeObjectAtIndex:0" on my array; not threadsafe.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeIdenticalPtr:

- (void) removeIdenticalPtr: (id) o

Locates an item in my array by enumerating through it and comparing the address of each item in the array to the passed ptr, and then deletes the matching item from the array; not threadsafe.

Implemented in MutNRLockArray.

◆ removeIdenticalPtrsInArray:

- (void) removeIdenticalPtrsInArray: (NSArray *) a

Calls "removeIdenticalPtrsInArray:" on my array; not threadsafe.

◆ removeLastObject

- (void) removeLastObject

Calls "removeLastObject" on my array; not threadsafe.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeObject:

- (void) removeObject: (id) o

Calls "removeObject:" on my array; not threadsafe.

Implemented in MutNRLockArray.

◆ removeObjectAtIndex:

- (void) removeObjectAtIndex: (NSUInteger) i

Calls "removeObjectAtIndex:" on my array; not threadsafe.

◆ removeObjectsAtIndexes:

- (void) removeObjectsAtIndexes: (NSIndexSet *) i

Calls "removeObjectsAtIndexes:" on my array; not threadsafe.

◆ removeObjectsInArray:

- (void) removeObjectsInArray: (NSArray *) otherArray

Calls "removeObjectsInArray:" on my array; not threadsafe.

◆ replaceObjectsAtIndexes:withObjects:

- (void) replaceObjectsAtIndexes: (NSIndexSet *) indexes
withObjects: (NSArray *) objects 

Calls "replaceObjectsAtIndexes:withObjects" on my array; not threadsafe.

◆ replaceWithObjectsFromArray:

- (void) replaceWithObjectsFromArray: (id) a

Calls "addObjectsFromArray" on my array; not threadsafe.

Implemented in MutNRLockArray.

◆ reverseObjectEnumerator

- (NSEnumerator *) reverseObjectEnumerator
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sortUsingDescriptors:

- (void) sortUsingDescriptors: (NSArray *) descriptors

Calls "sortUsingDescriptors:" on my array; not threadsafe.

◆ sortUsingSelector:

- (void) sortUsingSelector: (SEL) s

Calls "sortUsingSelector:" on my array; not threadsafe.

◆ unlock

- (void) unlock

Unlocks the array.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ valueForKey:

- (id) valueForKey: (NSString *) key

Calls "valueForKey:" on my array; not threadsafe.

◆ wrlock

- (void) wrlock

Establishes a write-lock for the array. Only one write-lock may exist at any given time, and all read-locks must be relinquished before the write-lock may be established (if you're going to change the array, nothing else can be changing or observing it).

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ array

- (NSMutableArray*) array
protected

Definition at line 21 of file MutLockArray.h.

◆ arrayLock

- (pthread_rwlock_t) arrayLock
protected

Definition at line 22 of file MutLockArray.h.


The documentation for this class was generated from the following file: