On 27 Apr 2009, at 20:22, James Maxwell wrote:

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.


Well, perhaps the main thread could be blocking, waiting for the other thread to respond to a message?

If you send a message to your dataThing object from your main thread, the main thread will wait for a response, and will not necessarily deal with all the events you want while waiting for the response.

As long as your dataThing API methods return void, you can avoid this problem by declaring the methods as 'oneway' ... which tells the distributed objects system that it can call the method asynchronously (so the main thread does not need to wait for a response).

Essentially the model needs to be that the main thread sends data to the dataThing thread using an asynchronous (oneway void) method, and the second thread then does computation, comes up with a result, and sends that result back to the main thread using another asynchronous method. That way, neither thread needs to wait for the other.

A big advantage of using NSConnection is that you an easily split your application into multiple processes (possibly running on multiple machines) rather than just multiple threads. However, if you don't need that option, and if you are targeting only the latest MacOS-X API, there is another approach you can take, using the -performSelector:onThread:withObject:waitUntilDone:modes: method of NSObject to send messages to a dataThing object in a second thread from the main thread. Using this new method is more efficient, but less flexible than using NSConnection.
_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to