• 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: Threadsafe function help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Threadsafe function help
      • From: Ken Tozier <email@hidden>
References: 
 >Threadsafe function help (From: Ken Tozier <email@hidden>)
 >Re: Threadsafe function help (From: Michael Ash <email@hidden>)
 >Re: Threadsafe function help (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: Threadsafe function help
  • Next by Date: Re: valueForKeyPath
  • Previous by thread: Re: Threadsafe function help
  • Next by thread: Re: Threadsafe function help
  • Index(es):
    • Date
    • Thread