• 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: Clarification: What is exatly drawing inside a thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Clarification: What is exatly drawing inside a thread


  • Subject: Re: Clarification: What is exatly drawing inside a thread
  • From: Glen Low <email@hidden>
  • Date: Sun, 8 Feb 2004 16:00:45 +0800

Probably because setStringValue: isn't an atomic operation and is not thread safe. So without a lock you will have several threads that are executing that method at the same time which might lead to all sorts of problems.

Or more general: How to determine, which operations DRAW and which do not?

I don't think this has anything to do with drawing at all.

Did you check what values the shared object actually holds? Try to log them and see what you get. I guess it will be the same garbage you see drawn to the screen.

In general, you always have to use locks when writing to shared resources from more than one thread.

I think it's even more severe than that. You may religiously use your own locks when using setStringValue: but there's no guarantee that the system i.e. Cocoa or AppKit will do so when accessing its data e.g. invalid rects or strings -- after all, any such lock is unknown by system code. For example, suppose setStringValue: updates the invalid rect at the same time as the system is using it to figure out what to draw -- by locking that code, you can be sure only one thread updates the invalid rect, but you haven't prevented the system from using it to figure out what to draw. lockFocusIfCanDraw does seem to use a lock known by Cocoa or AppKit.

It looks like a general method of getting what you want is using NSConnection to get a proxy of the NSTextView, then do a setStringValue on it. Others may want to comment whether an NSView is too heavyweight to be accessed through a proxy.

Cheers, Glen Low


---
pixelglow software | simply brilliant stuff
www.pixelglow.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.

  • Follow-Ups:
    • Re: Clarification: What is exatly drawing inside a thread
      • From: Stefan Pantke <email@hidden>
    • Re: Clarification: What is exatly drawing inside a thread
      • From: Andreas Mayer <email@hidden>
References: 
 >Clarification: What is exatly drawing inside a thread (From: Stefan Pantke <email@hidden>)
 >Re: Clarification: What is exatly drawing inside a thread (From: Andreas Mayer <email@hidden>)

  • Prev by Date: Re: Clarification: What is exatly drawing inside a thread
  • Next by Date: Changing a filename while the FSRef is in use
  • Previous by thread: Re: Clarification: What is exatly drawing inside a thread
  • Next by thread: Re: Clarification: What is exatly drawing inside a thread
  • Index(es):
    • Date
    • Thread