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

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

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






TKResource 






Inherits From:	TKObject

Declared In:	threadkit/TKResource.h





Class Description

The TKResource class provides a mechanism for locking and unlocking named resources.  The ThreadKit assumes no particular convention for naming resources, it just guarantees that no two threads may hold locks on the same name at any given time.

Applications for this class include protecting devices, files and thread-unsafe functions ... anything that doesn't have a convenient object representation to apply locking semantics to.  You may wish to prefix names with a type indicator to avoid namespace collisions (eg: "function:printf" vs. "file:printf" ).

For example, if an application wants to guarantee that printf() is never called by more than one thread at once, you could bracket all calls with lock and unlock operations as follows:

id		printfLock = [ TKResource findResourceFor: "function:printf" ] ;

[ printfLock threadLock ] ;

...

[ printfLock threadUnlock ] ;





Instance Variables

NXAtom name;



name 	A unique string naming the resource.





Method Types

Finding resources	+ findResourceFor:

Freeing TKResource instances	- free

Managing resource names	- setName:
- name





Class Methods

findResourceFor:
+ findResourceFor: (const char *) aString

Returns a TKResource instance with the name aString, or creates one if one does not already exist.




Instance Methods

free
- free

Removes the instance from the list of named resources before freeing it.




name
- (const char *) name

Returns the resource's current name.

See also:  - setName:




setName:
- setName: (const char *) aString

Returns nil if a resource with the given name already exists, otherwise changes the resource name to aString and returns self.

See also:  - name

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