ftp.nice.ch/pub/next/developer/objc/threads/ThreadedApp.1.0.s.tar.gz#/ThreadedApp-1.0/README.rtf

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

ThreadedApp v1.0
Chris Roehrig <croehrig@house.org>
March 1997


Writing multi-threaded applications in NEXTSTEP is not as easy as it could be.  I wrote ThreadedApp 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! 


ThreadedApp
Support for multi-threaded applications for NEXTSTEP 3.3. 

ThreadedApp 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. ThreadedApp 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.) 

ThreadedApp provides support for locking shared data or code via the CJRLock and CJRConditionLock 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 ThreadedApp 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 ThreadedApp 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 ThreadedApp's facilities in a simple way, and TestCounter which gives the ThreadedApp 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.

ThreadedApp.[hm]
Multi-threaded application support. See ThreadedApp.rtf.
	
CJRLock.[hm]
A locking facility.  See CJRLock.rtf.

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

Documentation
Documentation for the ThreadedApp and CJRLock classes.


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

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 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.