summaryrefslogtreecommitdiffstats
path: root/mojo/system/waiter.cc
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-13 23:12:50 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-13 23:12:50 +0000
commit1389053dca9b296f74d5704c62f6494aef1cbb63 (patch)
treef1bed144cf559be845c4c031a6ebbf9869b9e70f /mojo/system/waiter.cc
parent4540d58b344a1e284c5fa0224b748612fa9d84c3 (diff)
downloadchromium_src-1389053dca9b296f74d5704c62f6494aef1cbb63.zip
chromium_src-1389053dca9b296f74d5704c62f6494aef1cbb63.tar.gz
chromium_src-1389053dca9b296f74d5704c62f6494aef1cbb63.tar.bz2
Mojo: Update Waiter::Wait() to not put the context into the return value.
(Instead, it puts it into an out parameter.) Also reverse the order of the arguments to Waiter::Awake(). R=davemoore@chromium.org Review URL: https://codereview.chromium.org/337803002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277119 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/system/waiter.cc')
-rw-r--r--mojo/system/waiter.cc27
1 files changed, 12 insertions, 15 deletions
diff --git a/mojo/system/waiter.cc b/mojo/system/waiter.cc
index a7d18d3..5a3150d 100644
--- a/mojo/system/waiter.cc
+++ b/mojo/system/waiter.cc
@@ -18,8 +18,8 @@ Waiter::Waiter()
initialized_(false),
#endif
awoken_(false),
- awake_context_(static_cast<uint32_t>(-1)),
- awake_result_(MOJO_RESULT_INTERNAL) {
+ awake_result_(MOJO_RESULT_INTERNAL),
+ awake_context_(static_cast<uint32_t>(-1)) {
}
Waiter::~Waiter() {
@@ -36,7 +36,7 @@ void Waiter::Init() {
}
// TODO(vtl): Fast-path the |deadline == 0| case?
-MojoResult Waiter::Wait(MojoDeadline deadline) {
+MojoResult Waiter::Wait(MojoDeadline deadline, uint32_t* context) {
base::AutoLock locker(lock_);
#ifndef NDEBUG
@@ -48,10 +48,9 @@ MojoResult Waiter::Wait(MojoDeadline deadline) {
// Fast-path the already-awoken case:
if (awoken_) {
DCHECK_NE(awake_result_, MOJO_RESULT_INTERNAL);
- // TODO(vtl): This is a temporary hack until I add a |context| out parameter
- // and update all the call sites.
- return (awake_result_ == MOJO_RESULT_OK) ?
- static_cast<MojoResult>(awake_context_) : awake_result_;
+ if (context)
+ *context = awake_context_;
+ return awake_result_;
}
// |MojoDeadline| is actually a |uint64_t|, but we need a signed quantity.
@@ -69,30 +68,28 @@ MojoResult Waiter::Wait(MojoDeadline deadline) {
base::TimeDelta::FromMicroseconds(static_cast<int64_t>(deadline));
do {
base::TimeTicks now_time = base::TimeTicks::HighResNow();
- if (now_time >= end_time) {
+ if (now_time >= end_time)
return MOJO_RESULT_DEADLINE_EXCEEDED;
- }
cv_.TimedWait(end_time - now_time);
} while (!awoken_);
}
DCHECK_NE(awake_result_, MOJO_RESULT_INTERNAL);
- // TODO(vtl): This is a temporary hack until I add a |context| out parameter
- // and update all the call sites.
- return (awake_result_ == MOJO_RESULT_OK) ?
- static_cast<MojoResult>(awake_context_) : awake_result_;
+ if (context)
+ *context = awake_context_;
+ return awake_result_;
}
-void Waiter::Awake(uint32_t context, MojoResult result) {
+void Waiter::Awake(MojoResult result, uint32_t context) {
base::AutoLock locker(lock_);
if (awoken_)
return;
awoken_ = true;
- awake_context_ = context;
awake_result_ = result;
+ awake_context_ = context;
cv_.Signal();
// |cv_.Wait()|/|cv_.TimedWait()| will return after |lock_| is released.
}