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