Techniques for thread communication
Techniques for thread communication
- Subject: Techniques for thread communication
- From: Eric Scharff <email@hidden>
- Date: Sun, 7 Sep 2003 14:21:48 -0700 (PDT)
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.