vvopensource
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
Instance Methods | Class Methods
MutLockDict Class Reference

MutLockDict is a thread-safe version of NSMutableDictionary. More...

#import <MutLockDict.h>

Inherits NSObject.

Inherited by MutNRLockDict.

Instance Methods

(id) - initWithCapacity:
 functions similarly to the NSDictionary method- inits a MutLockDict with the supplied capacity
 
(void) - rdlock
 blocks until it can establish a read-lock on the array, and then returns. try to avoid calling this- using the built-in methods (which unlock before they return) is generally preferable/safer!
 
(void) - wrlock
 blocks until it can establish a write-lock on the array, and then returns. try to avoid calling this- using the built-in methods (which unlock before they return) is generally preferable/safer!
 
(void) - unlock
 unlocks and returns immediately
 
(NSMutableDictionary *) - dict
 returns the NSMutableDictionary used as the basis for this class- useful if you want to use fast iteration/that sort of thing
 
(NSMutableDictionary *) - createDictCopy
 creates a mutable, autoreleased copy of the dict and returns it. be careful, this method isn't threadsafe!
 
(NSMutableDictionary *) - lockCreateDictCopy
 creates a mutable, autoreleased copy of the dict and returns it. this method is threadsafe.
 
(void) - setObject:forKey:
 functions similar to the NSDictionary method, but checks to make sure you aren't trying to insert a nil value or use a nil key. not threadsafe!
 
(void) - lockSetObject:forKey:
 establishes a write-lock, then calls setObject:forKey:. threadsafe.
 
(void) - setValue:forKey:
 functions similar to the NSDictionary method- not threadsafe
 
(void) - lockSetValue:forKey:
 establishes a write-lock, then calls setValue:forKey:. threadsafe.
 
(void) - removeAllObjects
 removes all objects from the underlying dict- not threadsafe
 
(void) - lockRemoveAllObjects
 establishes a write-lock, then removes all objects from the underlying dict. threadsafe.
 
(id) - objectForKey:
 returns the object stored in the underlying dict at the passed key- not threadsafe
 
(id) - lockObjectForKey:
 establihes a read-lock, then returns the object stored in the underlying dict at the passed key. threadsafe.
 
(void) - removeObjectForKey:
 attempts to remove any object stored in the underlying dict at the passed key- not threadsafe.
 
(void) - lockRemoveObjectForKey:
 establishes a write-lock, then removes any object stored in the underlying dict at the passed key. threadsafe.
 
(void) - addEntriesFromDictionary:
 adds all entries from the passed dict to the receiver's underlying dictionary- not threadsafe.
 
(void) - lockAddEntriesFromDictionary:
 establishes a write-lock, then calls "addEntriesFromDictionary:". threadsafe.
 
(NSArray *) - allKeys
 returns an array with all the keys from the underlying dictionary- not threadsafe
 
(NSArray *) - lockAllKeys
 establishes a read-lock, then calls "allKeys". threadsafe.
 
(NSArray *) - allValues
 returns an array with all the values from the underlying dictionary- not threadsafe.
 
(NSArray *) - lockAllValues
 establishes a read-lock, then calls "allValues". threadsafe.
 
(void) - makeObjectsPerformSelector:
 calls "makeObjectsPerformSelector" on the array of values returned by the underlying dictionary- not threadsafe.
 
(void) - lockMakeObjectsPerformSelector:
 establishes a read-lock, then calls "makeObjectsPerformSelector:". threadsafe.
 
(NSInteger) - count
 returns the number of objects in the underlying dictionary- not threadsafe.
 
(NSInteger) - lockCount
 establishes a read-lock, then returns the number of objects in the underlying dictionary. threadsafe.
 

Class Methods

(id) + dictionaryWithCapacity:
 functions similarly to the NSDictionary method
 
(id) + dictionaryWithDict:
 functions similarly to the NSDictionary method- creates and returns an auto-released instance of MutLockDict populated with the contents of the passed dictionary
 

Detailed Description

MutLockDict is a thread-safe version of NSMutableDictionary.

This class exists because NSMutableDictionary is not thread-safe by default: if you call methods on it from two different threads at the same time, it will try to execute both, often crashing in the process. This class has methods which allow you to work with a mutable dictionary in a transparent and thread-safe manner.


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