Thanks for this. I actually found your page while googling around for help. I'll check it out now.

Cheers,

J.

Sent from my iPod

On 26-Apr-09, at 12:29 PM, Richard Frith-Macdonald <rich...@tiptree.demon.co.uk > wrote:


On 26 Apr 2009, at 18:39, James Maxwell wrote:

So, how can I put my dataThing into some process, thread, etc., in a way that keeps it totally in its "own world", so to speak?

There is a simple an easy way to keep it in a separate thread ... so that's probably what you want to do. You would use 'Distributed Objects' (the NSConnection class) to communicate between the main thread and the dataThing thread.

The way it works is as follows:

1. your code creates a pair of NSPort objects to talk to each other.
2. it launches a second thread, and in that thread creates a server NSConnection using those ports, and registers your dataThing object as the server object for the NSConnection 3. in the main thread another (client) NSConnection is created using the same two ports, and you ask the client connection for its 'root object'

From then on, the main thread sends messages to the 'root object' of the connection exactly as if it was sending them directly to the dataThing object, and the NSConnection code manages things for you so you don't have to worry about locking.

There's an example of this sort of thing at 
http://lachand.free.fr/cocoa/Threads.html
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to