• 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: Techniques for thread communication
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Techniques for thread communication


  • Subject: Re: Techniques for thread communication
  • From: Dustin Voss <email@hidden>
  • Date: Mon, 8 Sep 2003 13:38:57 -0700

The referenced message is for Toby Paterson's InterThreadCommunication library. It is not longer available at the listed address, but a while back I mirrored it on my iDisk:
http://homepage.mac.com/d.j.v./FileSharing3.html

On Sunday, September 7, 2003, at 02:37 PM, Tito Ciuro wrote:

Eric,

I'd choose another method, found in NSThread.h:

- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg
waitUntilDone:(BOOL)wait modes:(NSArray *)array;

- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg
waitUntilDone:(BOOL)wait;

The only problem is that these two methods are found in 10.2 and
onwards. If you want another option, I suggest looking at this post:

http://cocoa.mamasam.com/MACOSXDEV/2001/06/2/8592.php

I hope this helps,

-- Tito

On domingo, sept 7, 2003, at 23:21 Europe/Paris, Eric Scharff wrote:

I have a thread that continuously does computationally expensive
things in the background, but which occasionally needs to
present information to the user. Since the AppKit is mostly
not-reentrant, I want to make sure I do this the "right way."

It seems I have several options:

1. Use the NSNotificationCenter. The thread posts messages when
data is available, and the main app gets these events and
updates.

2. Use NSConnection to establish a communication channel between
the "main app" and the thread, and send messages through the
distributed object proxies.

3. Use an NSTimer in the main app to periodically poll the
thread.

4. Use NSInvocation somehow for the thread to push messages to
the main app.

I'm leaning heavily toward (1) because the code is the simplest
and cleanest. Option (2) is somewhat appealing because
eventually I could replace the local server with a cluster of
distributed servers.

Will these four approaches all work? Are there better ways?
What is the trade-off between these different techniques? Most
importantly, is there a big performance hit for using the
NSNotificationCenter?

Thanks,

-Eric


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Techniques for thread communication (From: Tito Ciuro <email@hidden>)

  • Prev by Date: a problem to show a dialog box in finder
  • Next by Date: benefits of introspection and loose typing
  • Previous by thread: Re: Techniques for thread communication
  • Next by thread: Re: Techniques for thread communication
  • Index(es):
    • Date
    • Thread