Re: [DynInst_API:] [PATCH] proccontrol: Avoid a destructor race on Counter::locks


Date: Fri, 16 May 2014 17:01:43 -0700
From: Josh Stone <jistone@xxxxxxxxxx>
Subject: Re: [DynInst_API:] [PATCH] proccontrol: Avoid a destructor race on Counter::locks
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.
[← Prev in Thread] Current Thread [Next in Thread→]