Re: Threadsafe function help
Re: Threadsafe function help
- Subject: Re: Threadsafe function help
- From: "Stephen J. Butler" <email@hidden>
- Date: Fri, 1 May 2009 00:35:07 -0500
On Fri, May 1, 2009 at 12:21 AM, Ken Tozier <email@hidden> wrote:
> I could see where scrollRangeToVisible might cause a problem, but wouldn't
> "length" be OK since it is just reading a value, not changing it?
Right, but the main thread might be changing it. Or might change it
after you've read it.
> How do you do that? The console view is a singleton and is initialized in
> the AppController awake from nib method before anything else executes. Is
> that enough to insure it is running on the main thread? May seem like a
> silly question but I'm far from comfortable working with threads. I haven't
> used them enough to know where the pitfalls and gotchas lie.
No, that means that the initialization occurs on the main thread.
Execution of any method dealing with the singleton is executed on the
thread where it is... executed. There's nothing automatic about it. So
if you call appendTime:message: on thread 101, then it executes on
thread 101, even if the object was created on thread 0.
So what you can do (and there are other ways too) is create a method
called appendTimeAndMessage:(NSArray*)someArguments and call that with
performSelectorOnMainThread and ilk.
_______________________________________________
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