• 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: How to count Atoms
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to count Atoms


  • Subject: Re: How to count Atoms
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 07 Oct 2016 12:09:11 -0500


On Fri, Oct 7, 2016, at 11:24 AM, Jens Alfke wrote:
>
> > On Oct 7, 2016, at 1:14 AM, Quincey Morris <email@hidden> wrote:
> >
> > 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).
>
> IMO dispatch_semaphore is overkill for this; it’s not just an atomic
> counter, it’s also got blocking behaviors for use in e.g. managing a pool
> of resources. I’ll bet that most Mac/iOS programmers don’t know about it,
> let alone people coming from other platforms.
>
> The simplest solution is just to use an atomic operation. Even if there
> isn’t a standard atomic API in C (as there is in C++), anyone reading the
> code is probably going to understand what OSAtomicIncrement32() does just
> from its name.

OSAtomic.h (except for OSAtomicQueue) is deprecated. Don’t use
OSAtomicIncrement32 in new code.

--Kyle Sluder

>
> —Jens

_______________________________________________

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: 
 >How to count Atoms (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to count Atoms (From: Quincey Morris <email@hidden>)
 >Re: How to count Atoms (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: How to count Atoms
  • Next by Date: Help - Epic Browser SPDY Encrypted Proxy Failing in Sierra
  • Previous by thread: Re: How to count Atoms
  • Next by thread: Re: How to count Atoms
  • Index(es):
    • Date
    • Thread