On 06/06/2012 07:25 PM, Amos Jeffries wrote: >>> + if (delta < head->best) >>> + head->best = delta; >>> + if (delta > head->worst) >>> + head->worst = delta; >>> + head->summ += delta; >>> + head->count++; >>> + head->overheads += get_tick() - stopped_; >> >> The above XProfilerNode::stop() code is not thread-safe because multiple >> threads may update the same "head" and you are not using atomics for >> *head members. > > Ok, for now this is the second major TODO. > I'm torn between GCC __sync_* and C++11 atomic_* types. > > There is maybe a wrapper compat layer needed temporarily I think.
Since SMP Squid already uses GCC __sync_* primitives and has the corresponding wrappers, consider reusing them for your project. See ipc/AtomicWord.h for a starting point. The existing wrappers can be adjusted to use C++11 atomic_* types when those are provided by the build environment, but that sounds like a very different project to me. HTH, Alex.
