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

Unified Diff: base/stats_table_unittest.cc

Issue 8972: Switch from the benighted PlatformThread to the shiny SimpleThread (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 months 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 | « base/stats_table.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/stats_table_unittest.cc
===================================================================
--- base/stats_table_unittest.cc (revision 4309)
+++ base/stats_table_unittest.cc (working copy)
@@ -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 @@
// 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 @@
// 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);
« no previous file with comments | « base/stats_table.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698