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

Re: Locks


  • Subject: Re: Locks
  • From: Conrad Shultz <email@hidden>
  • Date: Tue, 06 Dec 2011 16:39:05 -0800

On 12/6/11 3:28 PM, koko wrote:
> In windows we have:
>
> LONG volatile Mylock = 0;
> InterlockedIncrement(&Mylock);
> InterlockedDecrement(&Mylock);
>
>
> What should these be replaced with for OSX  as in :

Have you read the Threading Programming Guide?

I'm not a Windows developer, so I had to look up the MSDN docs, and
based on those it seems like you want the OSAtomicIncrementxxx (and
matching OSAtomicDecrementxxx) as direct analogues.

However, since it sounds like you are trying to use these functions to
implement locking in a multithreaded application, perhaps you should
also examine whether higher level constructs would prove sufficient.  A
couple such mechanisms you can read about are NSLock and the
@synchronized directive.  GCD has some features (dispatch semaphores and
barrier blocks come to mind) that may also be helpful in certain
circumstances.

--
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
_______________________________________________

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: Locks
      • From: koko <email@hidden>
References: 
 >Locks (From: koko <email@hidden>)

  • Prev by Date: Re: Exceptions and autorelease pools
  • Next by Date: Re: Locks
  • Previous by thread: Locks
  • Next by thread: Re: Locks
  • Index(es):
    • Date
    • Thread