• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTask, or threading?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask, or threading?


  • Subject: Re: NSTask, or threading?
  • From: James Maxwell <email@hidden>
  • Date: Mon, 27 Apr 2009 10:41:45 -0700

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


  • Follow-Ups:
    • Re: NSTask, or threading?
      • From: James Maxwell <email@hidden>
References: 
 >NSTask, or threading? (From: James Maxwell <email@hidden>)
 >Re: NSTask, or threading? (From: Richard Frith-Macdonald <email@hidden>)

  • Prev by Date: Re: figuring out which TableView I am?
  • Next by Date: NSTextField notification if selection changed
  • Previous by thread: Re: NSTask, or threading?
  • Next by thread: Re: NSTask, or threading?
  • Index(es):
    • Date
    • Thread