ftp.nice.ch/pub/next/developer/resources/classes/misckit/MiscKit.1.10.0.s.gnutar.gz#/MiscKit/Temp/ThreadedApp-1.1/README.rtf

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

MiscThreadedApp v1.1
Chris Roehrig <croehrig@house.org>
March 1997


Writing multi-threaded applications in NEXTSTEP is not as easy as it could be.  I wrote MiscThreadedApp to make it easy to write multi-threaded applications that use the AppKit.   In particular, it provides an easy mechanism for threads to use the AppKit features in a safe and robust way. 

So now there's no excuse not to use threads!   Let's make those Apps RESPONSIVE! 


QUICK INSTRUCTIONS 
First, run MAKE_SYM_LINKS to ensure that symbolic links are set up correctly.   This demo works with or without MiscKit.   If you don't have MiscKit installed, you'll first need to do:
	(cd misckit; make)
	rm -f Makefile.preamble
	ln -s Makefile.preamble.NOMISC Makefile.preamble

Then, just type make to build, and ThreadTest.app/ThreadTest to run.

MiscThreadedApp
Support for multi-threaded applications for NEXTSTEP 3.3. 

MiscThreadedApp is a subclass of Application that contains the functionality of the OpenStep NSThread object, but also provides increased support for interaction with the AppKit. The AppKit is not thread-safe and only the main thread can use it.  All other threads must message the main thread to perform any functions (drawing, etc) that involve the AppKit. MiscThreadedApp does this by introducing the notion of callback methods. This is a flexible mechanism whereby a thread can request that the main application thread invoke a method on its behalf.     This allows a thread to have virtually full access to the AppKit in a way that is easy to understand and use. 

The callback mechanism uses Mach messages to make requests to the main AppKit thread.   The main thread only receives the messages when it is in an event loop, so it is crucial that the main thread remains responsive to events. (This is only good user-interface design anyways.) 

MiscThreadedApp provides support for locking shared data or code via the MiscLock and MiscConditionLock classes.   These classes allow the main AppKit thread to "block" while waiting to acquire a lock, but still remain responsive to events so that other threads may still perform callbacks. 

Send any bug reports, comments, etc. to Chris Roehrig <croehrig@House.ORG> If you find MiscThreadedApp useful and are using it in an application, send me a note; I'd like to hear about it! 

    	-- Chris 


CONTENTS

ThreadTest Application
ThreadTest is a simple multi-threaded app for NEXTSTEP 3.3 that uses the MiscThreadedApp object.   It lets you start and stop (kill) any number of Counter instances.

ThreadTest.[hm]
This is the App's controller object.  It simply responds to the 2 menu commands New Test, and Kill.

ThreadTest.nib
The main NIB file for the app.  Only contains a main menu.

Counter.[hm]
This implements the Counter object.  There are two versions:  SimpleCounter which is an uncluttered demo to illustrate how to use the MiscThreadedApp's facilities in a simple way, and TestCounter which gives the MiscThreadedApp facilities a real workout.   Counter.[hm] are symbolic links to the one you want to use.

Experiment with the different ways of incrementing the counter to see the effect it has on windowserver performance.   

Counter.nib
Counter's NIB file.

tprintf.[hc]
A simple thread-safe version of printf.  

MiscKit files
ThreadedApp is now part of MiscKit and has been moved to the misckit directory.     

MiscThreadedApp.[hm]
Multi-threaded application support. See MiscThreadedApp.rtf.
	
MiscLock.[hm]
A locking facility.  See MiscLock.rtf and MiscConditionLock.rtf.

Documentation/*.rtf
Documentation for the MiscThreadedApp and MiscLock classes.


COPYRIGHT
Copyright 1997 Chris Roehrig <croehrig@House.ORG>
All Rights Reserved

Permission to redistribute and use in source and binary forms, with or without modification, is hereby granted, provided that the original author and copyright is acknowledged in all source code derived from this work. 

This object is included in the MiscKit by permission from the author and its use is governed by the MiscKit license, found in the file "License.rtf" in the MiscKit distribution.  Please refer to that file for a list of all applicable permissions and restrictions.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 

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