• 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: are the doc NSLock examples bogus?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: are the doc NSLock examples bogus?


  • Subject: Re: are the doc NSLock examples bogus?
  • From: John Stiles <email@hidden>
  • Date: Sun, 12 Feb 2006 10:22:25 -0800

I guess the reader can assume that all the magic happens inside the "..." block ;)
Seriously, the docs are definitely less than intuitive there; I'd say file a documentation bug.


Matt Neuburg wrote:
With reference to:

<http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/ar
ticles/CocoaLocks.html>

and this example:

BOOL moreToDo = YES;
NSLock *theLock = [[NSLock alloc] init];
...
while (moreToDo) {
    /* Do another increment of calculation */
    /* until there¹s no more to do. */
    if ([theLock tryLock]) {
        /* Update display used by all threads. */
        [theLock unlock];
    }
}

If this code is encountered by several different threads, then theLock is
created separately by each thread. Unless locks are magic, this would
presumably mean that locking theLock in thread A would have no effect on
theLock in thread B. So can I assume that examples of this type (which
permeate the thread docs) are just bogus?

Thx - m.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >are the doc NSLock examples bogus? (From: Matt Neuburg <email@hidden>)

  • Prev by Date: are the doc NSLock examples bogus?
  • Next by Date: Re: Affine Transform
  • Previous by thread: are the doc NSLock examples bogus?
  • Next by thread: Re: are the doc NSLock examples bogus?
  • Index(es):
    • Date
    • Thread