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

Unified Diff: test/cctest/test-debug.cc

Issue 23625003: Cleanup Mutex and related classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 7 years, 4 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 | « test/cctest/cctest.gyp ('k') | test/cctest/test-lock.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 9281337dbd58615e11329aa5bb794d2bf44208f4..c12cb58309b7a5eb0932ced7c40960032378c999 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -4678,14 +4678,13 @@ class ThreadBarrier {
private:
int num_threads_;
int num_blocked_;
- v8::internal::Mutex* lock_;
+ v8::internal::Mutex lock_;
v8::internal::Semaphore* sem_;
bool invalid_;
};
ThreadBarrier::ThreadBarrier(int num_threads)
: num_threads_(num_threads), num_blocked_(0) {
- lock_ = OS::CreateMutex();
sem_ = OS::CreateSemaphore(0);
invalid_ = false; // A barrier may only be used once. Then it is invalid.
}
@@ -4694,14 +4693,12 @@ ThreadBarrier::ThreadBarrier(int num_threads)
// Do not call, due to race condition with Wait().
// Could be resolved with Pthread condition variables.
ThreadBarrier::~ThreadBarrier() {
- lock_->Lock();
- delete lock_;
delete sem_;
}
void ThreadBarrier::Wait() {
- lock_->Lock();
+ lock_.Lock();
CHECK(!invalid_);
if (num_blocked_ == num_threads_ - 1) {
// Signal and unblock all waiting threads.
@@ -4711,10 +4708,10 @@ void ThreadBarrier::Wait() {
invalid_ = true;
printf("BARRIER\n\n");
fflush(stdout);
- lock_->Unlock();
+ lock_.Unlock();
} else { // Wait for the semaphore.
++num_blocked_;
- lock_->Unlock(); // Potential race condition with destructor because
+ lock_.Unlock(); // Potential race condition with destructor because
sem_->Wait(); // these two lines are not atomic.
}
}
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-lock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698