Re: NSTask, or threading?
Re: NSTask, or threading?
- Subject: Re: NSTask, or threading?
- From: James Maxwell <email@hidden>
- Date: Mon, 27 Apr 2009 12:22:48 -0700
ugh... Okay, so I got rid of all the shared instances (of my own
classes, that is) but I'm still getting stuttering. Is there anything
in the settings of the thread itself that I should check? Or is there
some other newbie "gotcha" that I should be aware of?
thanks in advance for any thoughts...
J.
On 27-Apr-09, at 10:41 AM, James Maxwell wrote:
Thanks Richard, that's really helpful!
I seem to have it working, though I'm actually still having problems
with stuttering, which I don't really understand. Any thoughts on
where I should start looking? Could it be because some of the
classes in my worker thread are using shared instances? Do shared
instances automatically involve the main thread somehow?
thanks,
J.
On 26-Apr-09, at 12:29 PM, Richard Frith-Macdonald 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 (email@hidden)
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:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden