Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Unified Diff: base/tracked_objects.h

Issue 8587031: Avoid any possibility of an Alloc during TLS thread teardown (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/tracked_objects.cc » ('j') | base/tracked_objects.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/tracked_objects.h
===================================================================
--- base/tracked_objects.h (revision 110300)
+++ base/tracked_objects.h (working copy)
@@ -525,10 +525,31 @@
// in production code.
friend class TrackedObjectsTest;
- typedef std::stack<const ThreadData*> ThreadDataPool;
+ // Implment a stack that avoids allocations during a push() by having enough
ramant (doing other things) 2011/11/17 22:59:36 nit: Implment -> Implement
+ // space ahead of time.
+ class ThreadDataPool {
+ public:
+ ThreadDataPool();
+ ~ThreadDataPool();
+ // Make sure the stack is large enough to support the indicated number of
+ // elements.
+ void reserve(size_t largest_worker_pool_number);
+
+ bool empty() const;
+ const ThreadData* top() const;
+ void push(const ThreadData* thread_data);
+ void pop();
+
+ private:
+ std::vector<const ThreadData*> stack_;
+ size_t empty_slot_;
+ DISALLOW_COPY_AND_ASSIGN(ThreadDataPool);
+ };
+
// Worker thread construction creates a name since there is none.
- ThreadData();
+ explicit ThreadData(size_t thread_number);
+
// Message loop based construction should provide a name.
explicit ThreadData(const std::string& suggested_name);
@@ -616,7 +637,9 @@
// Indicate if this is a worker thread, and the ThreadData contexts should be
// stored in the unregistered_thread_data_pool_ when not in use.
- bool is_a_worker_thread_;
+ // Value is zero when it is not a worker thread. Value is a positive integer
+ // corresponding to the created thread name if it is a worker thread.
+ size_t worker_thread_number_;
// A map used on each thread to keep track of Births on this thread.
// This map should only be accessed on the thread it was constructed on.
« no previous file with comments | « no previous file | base/tracked_objects.cc » ('j') | base/tracked_objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698