[llvm-commits] [llvm] r73916 - /llvm/trunk/lib/Support/Statistic.cpp
Owen Anderson
resistor at mac.com
Mon Jun 22 16:08:27 PDT 2009
Author: resistor
Date: Mon Jun 22 18:08:27 2009
New Revision: 73916
URL: http://llvm.org/viewvc/llvm-project?rev=73916&view=rev
Log:
Guard the statistics table.
Modified:
llvm/trunk/lib/Support/Statistic.cpp
Modified: llvm/trunk/lib/Support/Statistic.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Statistic.cpp?rev=73916&r1=73915&r2=73916&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Statistic.cpp (original)
+++ llvm/trunk/lib/Support/Statistic.cpp Mon Jun 22 18:08:27 2009
@@ -25,6 +25,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Streams.h"
+#include "llvm/System/Mutex.h"
#include "llvm/ADT/StringExtras.h"
#include <algorithm>
#include <ostream>
@@ -57,13 +58,14 @@
}
static ManagedStatic<StatisticInfo> StatInfo;
-
+static ManagedStatic<sys::Mutex> StatLock;
/// RegisterStatistic - The first time a statistic is bumped, this method is
/// called.
void Statistic::RegisterStatistic() {
// If stats are enabled, inform StatInfo that this statistic should be
// printed.
+ sys::ScopedLock Writer(&*StatLock);
if (Enabled)
StatInfo->addStatistic(this);
// Remember we have been registered.
More information about the llvm-commits
mailing list