On 05/16/2014 04:03 PM, Josh Stone wrote:
> +Mutex<false> * Counter::locks = new Mutex<false>[Counter::NumCounterTypes];
> int Counter::global_counts[Counter::NumCounterTypes];
FWIW, I considered ditching the mutexes and making global_counts[] use
atomic<int>, but we don't yet live in a world where that is portable.
RHEL6 doesn't have boost::atomic. It does have std::atomic, but it's
found in <cstdatomic> rather than <atomic>. On Windows, the builders
are using VS10, which doesn't have std::atomic. At least there we could
use new enough boost for boost::atomic. Or either could use intrinsics,
via GCC __sync_fetch_and_add or Windows InterlockedAdd, but that's not
even trying to be portable.
So rather than a bunch of platform ifdefs, I chose to just make the
existing mutexes work more consistently.
|