Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/Thread.cpp

Issue 10026001: Cross-platform thread primitives (Closed)
Patch Set: Improve mutex test Created April 4, 2013, 7:27 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/Thread.cpp
===================================================================
--- a/test/Thread.cpp
+++ b/test/Thread.cpp
@@ -37,16 +37,17 @@
public:
bool working;
- LockingMock(const std::string& name, std::vector<std::string>& log,
- AdblockPlus::Mutex& logMutex)
- : name(name), log(log), logMutex(logMutex)
+ LockingMock(std::vector<std::string>& log, AdblockPlus::Mutex& logMutex)
+ : log(log), logMutex(logMutex)
{
}
void Run()
{
logMutex.Lock();
- log.push_back(name);
+ log.push_back("started");
+ Sleep(5);
+ log.push_back("ended");
logMutex.Unlock();
}
@@ -120,15 +121,16 @@
{
std::vector<std::string> log;
AdblockPlus::Mutex logMutex;
- LockingMock mock1("mock1", log, logMutex);
- LockingMock mock2("mock2", log, logMutex);
+ LockingMock mock1(log, logMutex);
+ LockingMock mock2(log, logMutex);
mock1.Start();
- Sleep(5);
mock2.Start();
mock1.Join();
mock2.Join();
- ASSERT_EQ("mock1", log[0]);
- ASSERT_EQ("mock2", log[1]);
+ ASSERT_EQ("started", log[0]);
+ ASSERT_EQ("ended", log[1]);
+ ASSERT_EQ("started", log[2]);
+ ASSERT_EQ("ended", log[3]);
}
TEST(ThreadTest, ConditionVariable)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld