Re: How to count Atoms
Re: How to count Atoms
- Subject: Re: How to count Atoms
- From: Quincey Morris <email@hidden>
- Date: Fri, 07 Oct 2016 01:14:47 -0700
- Feedback-id: 167118m:167118agrif8a:167118s1y6_KlIuo:SMTPCORP
On Oct 7, 2016, at 00:19 , Gerriet M. Denkmann <email@hidden> wrote:
>
> So what is the proper way to count something atomicly and undeprecatedly?
One straightforward way is to use dispatch_semaphore. IIRC it’s lightweight unless it blocks (that is, unless its count is zero when you wait), so it’s good for this situation where actual contention is rare (assuming actual contention is rare).
If performance is not a consideration, you can use @synchronized instead. It’s marginally easier to use.
_______________________________________________
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