summaryrefslogtreecommitdiffstats
path: root/mojo/system/waiter.cc
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-21 19:44:48 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-21 19:44:48 +0000
commitf1c0c49bdc506aff047bd64d343bfd30d0e3f327 (patch)
treed6a4ab151f03251487881cb09fa7d8a85f18b2b7 /mojo/system/waiter.cc
parent15d0233ec7c7f5407c5612dcda1a09466316f213 (diff)
downloadchromium_src-f1c0c49bdc506aff047bd64d343bfd30d0e3f327.zip
chromium_src-f1c0c49bdc506aff047bd64d343bfd30d0e3f327.tar.gz
chromium_src-f1c0c49bdc506aff047bd64d343bfd30d0e3f327.tar.bz2
Mojo: Add debug-only checks to Waiter that check that Init() has been called.
(And fix a test that didn't follow the contract properly.) R=davemoore@chromium.org Review URL: https://codereview.chromium.org/28983006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229889 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/system/waiter.cc')
-rw-r--r--mojo/system/waiter.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/mojo/system/waiter.cc b/mojo/system/waiter.cc
index 6dda21f..754ece1 100644
--- a/mojo/system/waiter.cc
+++ b/mojo/system/waiter.cc
@@ -14,6 +14,9 @@ namespace system {
Waiter::Waiter()
: cv_(&lock_),
+#ifndef NDEBUG
+ initialized_(false),
+#endif
awoken_(false),
wait_result_(MOJO_RESULT_INTERNAL) {
}
@@ -22,6 +25,9 @@ Waiter::~Waiter() {
}
void Waiter::Init() {
+#ifndef NDEBUG
+ initialized_ = true;
+#endif
awoken_ = false;
// NOTE(vtl): If performance ever becomes an issue, we can disable the setting
// of |wait_result_| (except the first one in |Awake()|) in Release builds.
@@ -32,6 +38,12 @@ void Waiter::Init() {
MojoResult Waiter::Wait(MojoDeadline deadline) {
base::AutoLock locker(lock_);
+#ifndef NDEBUG
+ DCHECK(initialized_);
+ // It'll need to be re-initialized after this.
+ initialized_ = false;
+#endif
+
// Fast-path the already-awoken case:
if (awoken_) {
DCHECK_NE(wait_result_, MOJO_RESULT_INTERNAL);