Re: Multithreaded Cocoa Document Application?
Re: Multithreaded Cocoa Document Application?
- Subject: Re: Multithreaded Cocoa Document Application?
- From: Andrew Merenbach <email@hidden>
- Date: Thu, 23 Aug 2007 18:36:34 -0700
Hi, Rick,
Shawn corrected me, as I was right only in my narrow mindset: you
cannot actually *open* a document in a separate thread; Cocoa handles
is in its own way.
You can, however--as Shawn pointed out--open the documents normally,
then start a thread from *within* each document. That should do the
trick.
As for communication, your best bet is probably
NSDistributedNotifications.
Cheers,
Andrew
On Aug 23, 2007, at 6:21 PM, Rick Ekle wrote:
Andrew (and others)
If I can't do this in a multithreaded Document based Cocoa App,
then the next question, is how would I be able to select multiple
documents and launch each in a separate instance of the
application? It seems like OS X always launches multiple documents
into a single application process. If I could run each document in
a separate process, that would be fine. The different douments are
all independent and really don't need to have any communication
between each other.
Forgive the basic questions... I'm still new to Cocoa...
Rick
Andrew Merenbach wrote:
Hi, Rick,
I'm not an expert on interthread communication, but I believe that
you may wish to look into NSDistributedNotifications for this:
The NSDistributedNotificationCenter class provides a way to send
notifications to objects in other tasks. It takes NSNotification
objects and broadcasts them to any objects in other tasks that
have registered for the notification with their task’s default
distributed notification center.
Unfortunately, your multi-document idea won't work with a subclass
of NSDocument, as NSDocument is provided by AppKit and AppKit is
not thread-safe.
HTH,
Andrew
On Aug 23, 2007, at 5:56 PM, Rick Ekle wrote:
Does anyone have an example of how to write a Cocoa application so
that each document is handled in a separate thread? Either that
or a
way to open a series of documents and have each open in a separate
process..
I'm trying to write an application that can open multiple files at
once and perform some potentially long processing on each. I'd like
to have each document open in a separate thread or process so
that the
application can better take advantage of a multicore processor to
process multiple files simultaneously.
Any ideas?
Also, the NSThread class seems to simply launch threads. These
threads are launched but there is no way to know anything about
them.
How do you monitor a thread and wait for it to exit? How do force a
thread to exit early? Would I have to resort to pthreads to get
this
kind of functionality? NSThread seems kinda useless if you have no
way to communicate between threads..
Thanks for the help,
Rick
_______________________________________________
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:
40ucla.edu
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
_______________________________________________
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