LLLLThreadWorker Class Reference

#include <LLThreadWorker.h>


Detailed Description

v0.7 - Throws a task onto another thread and notifies you when it's done.

Usage:

[LLThreadWorker 
        workOn:self 
  withSelector:&#064;selector(longTask:) 
    withObject:someData
didEndSelector:&#064;selector(longTaskFinished:) ];
The LLThreadWorker class was designed to be simple and to make multi-threading even simpler. You can offload tasks to another thread and be notified when the task is finished.

In this sense it is similar to the Java SwingWorker class, though the need for such a class in Cocoa and Objective-C is as different as the implementation.

Be sure to copy the LLThreadWorker.h and LLThreadWorker.m files to your project directory.

To see how to use this class, see the documentation for the "workOn" method below.

I recommend registering at the link below to let SourceForge contact you when new versions of LLThreadWorker are released:

http://sourceforge.net/project/filemodule_monitor.php?filemodule_id=24102

I'm releasing this code into the Public Domain. Do with it as you will. Enjoy!

Original author: Robert Harder, rob&#064;iharder.net

Change History

0.7 -
 o  Added ability to mark thread as cancelled.
 o  Changed the behavior when "longTask" takes a second argument.
    Instead of passing a proxy to the primary thread's "self"
    it passes a references to the LLThreadWorker. The recommended way
    to pass information from the primary, or originating, thread
    is to use an NSDictionary to pass in the Things You'll Need.
    See the Controller.m example.
 o  Changed thread's termination behavior so that as soon as your
    "longTask:" is finished, the thread will exit. This means if
    you left anything on the NSRunLoop (or more likely an NSURL
    did it without your knowledge), it will get dumped.

0.6.2 - Moved [super dealloc] to the end of the dealloc method and
ensured "init" returns nil if it fails.

0.6.1 - Added [super dealloc] to the dealloc method and moved the
dealloc declaration out of the private API and into the
public .h file as it should be.

0.6 - Eliminated the need for the runSelectorInCallingThread method
by making a proxy to the target available to the task working
in the new thread. This makes for much less overhead.
Also changed static method signature from withArgument to withObject.

0.5.1 - Oops. Forget a necessary thread lock for the NSConnection creation.

0.5 - Uses NSConnection to communicate between threads, so although we
might have been thread-safe before (depending on whether or not
addTimer in NSRunLoop is thread-safe), we're definitely thread-safe
now - or so we think. =)
In the process we had to do away with the helper functions that took
a bit of hassle out using runSelectorInCallingThread with arguments
that are not objects. Sorry.

0.4.1 - Fixed some typos in commented sections.

0.4 - Released into the Public Domain. Enjoy!

0.3 - Permitted "workOn" method to accept a second argument of type
LLThreadWorker* to allow for passing of the parent LLThreadWorker
to the secondary thread. This makes it easy and reliable to
call other methods on the calling thread.

0.2 - Added runSelectorInCallingThread so that you could make calls
back to the main, i.e. calling, thread from the secondary thread.

0.1 - Initial release.


The documentation for this class was generated from the following file:
Generated on Sat Aug 26 21:14:40 2006 for MacTrek by  doxygen 1.4.7