summaryrefslogtreecommitdiffstats
path: root/base/stats_table.h
diff options
context:
space:
mode:
authordkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-31 19:21:34 +0000
committerdkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-31 19:21:34 +0000
commitbb47a94f2a1e5c9bc7d5e0e40cc64e8b791134a3 (patch)
treedcc51a6445b4d410aea493094b322bdf0dcb31c7 /base/stats_table.h
parent50b691cc2cfdbb3b39e05c6c1632d6e9276f52d1 (diff)
downloadchromium_src-bb47a94f2a1e5c9bc7d5e0e40cc64e8b791134a3.zip
chromium_src-bb47a94f2a1e5c9bc7d5e0e40cc64e8b791134a3.tar.gz
chromium_src-bb47a94f2a1e5c9bc7d5e0e40cc64e8b791134a3.tar.bz2
Port last remaining test case in base/stats_table_unittest.cc, and
fix the bug it exposes on posix in StatsTable, i.e. UnregisterThread() breaks when called inside SlotReturnFunction() on posix because posix clears tls data before calling destructor. Review URL: http://codereview.chromium.org/8751 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4309 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/stats_table.h')
-rw-r--r--base/stats_table.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/base/stats_table.h b/base/stats_table.h
index 8ef529c..48da71a 100644
--- a/base/stats_table.h
+++ b/base/stats_table.h
@@ -76,11 +76,6 @@ class StatsTable {
// returns 0.
int RegisterThread(const std::wstring& name);
- // Returns the space occupied by a thread in the table. Generally used
- // if a thread terminates but the process continues. This function
- // does not zero out the thread's counters.
- void UnregisterThread();
-
// Returns the number of threads currently registered. This is really not
// useful except for diagnostics and debugging.
int CountThreadsRegistered() const;
@@ -137,6 +132,20 @@ class StatsTable {
static int* FindLocation(const wchar_t *name);
private:
+ // Returns the space occupied by a thread in the table. Generally used
+ // if a thread terminates but the process continues. This function
+ // does not zero out the thread's counters.
+ // Cannot be used inside a posix tls destructor.
+ void UnregisterThread();
+
+ // This variant expects the tls data to be passed in, so it is safe to
+ // call from inside a posix tls destructor (see doc for pthread_key_create).
+ void UnregisterThread(StatsTableTLSData* tls_data);
+
+ // The SlotReturnFunction is called at thread exit for each thread
+ // which used the StatsTable.
+ static void SlotReturnFunction(void* data);
+
// Locates a free slot in the table. Returns a number > 0 on success,
// or 0 on failure. The caller must hold the shared_memory lock when
// calling this function.