summaryrefslogtreecommitdiffstats
path: root/base/stats_table_unittest.cc
diff options
context:
space:
mode:
authordkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-03 20:08:45 +0000
committerdkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-03 20:08:45 +0000
commit2c3863845eeea62e1012efb177fa415bf639cc5d (patch)
tree4d47c69b300994216234e7bb44b3a3d31639ea0c /base/stats_table_unittest.cc
parentf29acf538815f1d71638ac9db8798998a113955f (diff)
downloadchromium_src-2c3863845eeea62e1012efb177fa415bf639cc5d.zip
chromium_src-2c3863845eeea62e1012efb177fa415bf639cc5d.tar.gz
chromium_src-2c3863845eeea62e1012efb177fa415bf639cc5d.tar.bz2
Switch from the benighted PlatformThread to the shiny SimpleThread
Also add a comment to explain the strange tls gyrations in SlotReturnFunction. Review URL: http://codereview.chromium.org/8972 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/stats_table_unittest.cc')
-rw-r--r--base/stats_table_unittest.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/base/stats_table_unittest.cc b/base/stats_table_unittest.cc
index 87ad47f..0ce99b7 100644
--- a/base/stats_table_unittest.cc
+++ b/base/stats_table_unittest.cc
@@ -4,6 +4,7 @@
#include "base/multiprocess_test.h"
#include "base/platform_thread.h"
+#include "base/simple_thread.h"
#include "base/stats_table.h"
#include "base/stats_counters.h"
#include "base/string_util.h"
@@ -66,14 +67,16 @@ const std::wstring kCounterMixed = L"CounterMixed";
// The number of thread loops that we will do.
const int kThreadLoops = 1000;
-class StatsTableThread : public PlatformThread::Delegate {
+class StatsTableThread : public base::SimpleThread {
public:
- void ThreadMain();
- PlatformThreadHandle thread_;
+ StatsTableThread(std::string name, int id)
+ : base::SimpleThread(name), id_(id) { }
+ virtual void Run();
+private:
int id_;
};
-void StatsTableThread::ThreadMain() {
+void StatsTableThread::Run() {
// Each thread will open the shared memory and set counters
// concurrently in a loop. We'll use some pauses to
// mixup the thread scheduling.
@@ -110,21 +113,20 @@ TEST_F(StatsTableTest, MultipleThreads) {
// Spin up a set of threads to go bang on the various counters.
// After we join the threads, we'll make sure the counters
// contain the values we expected.
- StatsTableThread threads[kMaxThreads];
+ StatsTableThread* threads[kMaxThreads];
// Spawn the threads.
for (int index = 0; index < kMaxThreads; index++) {
- threads[index].id_ = index;
- bool created =
- PlatformThread::Create(0, &threads[index], &threads[index].thread_);
- EXPECT_EQ(true, created);
- EXPECT_NE(static_cast<PlatformThreadHandle>(0), threads[index].thread_);
+ threads[index] = new StatsTableThread("MultipleThreadsTest", index);
+ threads[index]->Start();
}
// Wait for the threads to finish.
for (int index = 0; index < kMaxThreads; index++) {
- PlatformThread::Join(threads[index].thread_);
+ threads[index]->Join();
+ delete threads[index];
}
+
StatsCounter zero_counter(kCounterZero);
StatsCounter lucky13_counter(kCounter1313);
StatsCounter increment_counter(kCounterIncrement);