ftp.nice.ch/pub/next/developer/resources/libraries/threadkit/ThreadKitDemo.NI.tar.gz#/ThreadKit-1.0-DEMO/Documentation/ThreadKit/Classes/ObjectAdditions.rtf

This is ObjectAdditions.rtf in view mode; [Download] [Up]

Release 1.0  Copyright ©1994 by Arcane Systems Ltd.  All Rights Reserved.




Object Additions






Inherits From:	none  (Object is the root class.)

Conforms To:	TKThreadLocking

Declared In:	threadkit/Object-TKThreadLocking.h





Class Description

The ThreadKit adds seven methods to the root Object class, the six defined by the TKThreadLocking protocol and threadKitLockObject.  These methods are available in every class in an application that uses the ThreadKit.

Only these methods are described here.  See NeXT's documentation for a general description of the Object class and the methods it defines.





Instance Methods

threadKitLockObject
- threadKitLockObject

Returns the instance of TKObject being used to manage locks for the recipient, creating one if one does not already exist.




threadLock
- threadLock

If the object is already locked by the calling thread, the lock count is incremented by one.  Otherwise, this method waits until no other thread holds a lock on the object.  The object is then locked, setting the lock count to one.  As a result only one thread may lock an object at any given time and paired sets of lock / unlock operations may be nested as deeply as desired.  Returns self once the lock has been aquired.




threadLockWhen:
- threadLockWhen: (int) state

Behaves in the same manner as threadLock except that it will not lock an unlocked object whose state is not equal to state.  It will wait while object is locked and unlocked by other threads until it is unlocked with the proper state.  Returns self once the lock has been aquired.

state should normally be a positive integer value. Calling this method with the constant TK_ANY_STATE is equivelant to calling threadLock.




threadUnlock
- threadUnlock

Returns nil if the calling thread doesn't currently hold a lock on the object.  Otherwise reduces the internal lock count by one and returns self.  Once the lock count reaches zero, the object is unlocked and its state is set to zero.




threadUnlockWith:
- threadUnlockWith: (int) state

Behaves in the same manner as threadUnlock except that when the lock count reaches zero, the object is unlocked and its state is set to state.

state should normally be a positive integer value.  Calling this method with the constant TK_DEFAULT_STATE is equivelant to calling threadUnlock.




tryThreadLock
- (BOOL) tryThreadLock

Behaves in the same manner as threadLock except that it always returns immediately.  Since a lock is not always available immediately, the method returns YES if the lock was successfully aquired, and NO otherwise.




tryThreadLockFor:
- tryThreadLockFor: (int) state

Behaves in the same manner as threadLockWhen: except that it always returns immediately.  Since a lock is not always available immediately, the method returns YES if the lock was successfully aquired, and NO otherwise.

state should normally be a positive integer value.  Calling this method with the constant TK_ANY_STATE is equivelant to calling tryThreadLock.  Calling this method with the constant TK_RECURSIVE_STATE will succeed only if the thread already has a valid lock.

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.