Index: base/tracked_objects.h |
=================================================================== |
--- base/tracked_objects.h (revision 7482) |
+++ base/tracked_objects.h (working copy) |
@@ -39,7 +39,7 @@ |
// allowed to access birth_count_ (which changes over time). |
const ThreadData* birth_thread_; // The thread this birth took place on. |
- DISALLOW_EVIL_CONSTRUCTORS(BirthOnThread); |
+ DISALLOW_COPY_AND_ASSIGN(BirthOnThread); |
}; |
//------------------------------------------------------------------------------ |
@@ -62,7 +62,7 @@ |
// The number of births on this thread for our location_. |
int birth_count_; |
- DISALLOW_EVIL_CONSTRUCTORS(Births); |
+ DISALLOW_COPY_AND_ASSIGN(Births); |
}; |
//------------------------------------------------------------------------------ |
@@ -183,7 +183,7 @@ |
Lock accumulation_lock_; // Protects access during accumulation phase. |
- DISALLOW_EVIL_CONSTRUCTORS(DataCollector); |
+ DISALLOW_COPY_AND_ASSIGN(DataCollector); |
}; |
//------------------------------------------------------------------------------ |
@@ -209,7 +209,7 @@ |
DeathData death_data_; |
std::map<const ThreadData*, int> death_threads_; |
- DISALLOW_EVIL_CONSTRUCTORS(Aggregation); |
+ DISALLOW_COPY_AND_ASSIGN(Aggregation); |
}; |
//------------------------------------------------------------------------------ |
@@ -428,7 +428,7 @@ |
// Make sure enough tasks are called before completion is signaled. |
ThreadSafeDownCounter* counter_; |
- DISALLOW_EVIL_CONSTRUCTORS(RunTheStatic); |
+ DISALLOW_COPY_AND_ASSIGN(RunTheStatic); |
}; |
#endif |
@@ -480,9 +480,35 @@ |
// data, but that is considered acceptable errors (mis-information). |
Lock lock_; |
- DISALLOW_EVIL_CONSTRUCTORS(ThreadData); |
+ DISALLOW_COPY_AND_ASSIGN(ThreadData); |
}; |
+ |
+//------------------------------------------------------------------------------ |
+// Provide simple way to to start global tracking, and to tear down tracking |
+// when done. Note that construction and destruction of this object must be |
+// done when running in single threaded mode (before spawning a lot of threads |
+// for construction, and after shutting down all the threads for destruction). |
+ |
+class AutoTracking { |
+ public: |
+ AutoTracking() { ThreadData::StartTracking(true); } |
+ |
+ ~AutoTracking() { |
+#ifndef NDEBUG // Don't call these in a Release build: they just waste time. |
+ // The following should ONLY be called when in single threaded mode. It is |
+ // unsafe to do this cleanup if other threads are still active. |
+ // It is also very unnecessary, so I'm only doing this in debug to satisfy |
+ // purify (if we need to!). |
+ ThreadData::ShutdownSingleThreadedCleanup(); |
+#endif |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(AutoTracking); |
+}; |
+ |
+ |
} // namespace tracked_objects |
#endif // BASE_TRACKED_OBJECTS_H_ |