• 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
NSConditionLock vs. plain variable question...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSConditionLock vs. plain variable question...


  • Subject: NSConditionLock vs. plain variable question...
  • From: "Juan P. Pertierra" <email@hidden>
  • Date: Tue, 9 May 2006 21:01:48 -0400

Hello,

My Cocoa application has a background thread which contains an async callback function which gets periodically called by the system.

At one point, my main thread wants to change the value of a single variable which is used in the callback, so I want to make sure a callback is not in progress before changing it.

I'd like to keep the callback as simple as possible. Is there any reason not to use just a simple global variable "inCallback", set it to "1" at the beginning at the callback and set it to "0" at the end of the callback, then just check it in the main thread? i.e. if "inCallback == 1" then wait to change the variable, until "inCallback == 0". It seems like NSConditionLock/NSLock will have more overhead than just changing the value of a variable, but I'm probably wrong.

Thanks,
Juan
_______________________________________________
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


  • Follow-Ups:
    • Re: NSConditionLock vs. plain variable question...
      • From: Shaun Wexler <email@hidden>
    • Re: NSConditionLock vs. plain variable question...
      • From: Lon Giese <email@hidden>
    • Re: NSConditionLock vs. plain variable question...
      • From: "Shawn Erickson" <email@hidden>
  • Prev by Date: Re: Question regarding getRectsBeingDrawn:'s constant array pointer argument (const NSRect **)
  • Next by Date: Re: NSConditionLock vs. plain variable question...
  • Previous by thread: Re: Does there exist a Cocoa compatibility test tool?
  • Next by thread: Re: NSConditionLock vs. plain variable question...
  • Index(es):
    • Date
    • Thread