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

Unified Diff: mojo/edk/system/waiter.cc

Issue 2075353002: Plumb the handle signals state out of Waiter::Wait(). (Closed) Base URL: https://github.com/domokit/mojo.git@work795_wait_set_4.3-x-work794_wait_set_4.2
Patch Set: Created 4 years, 6 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 | « mojo/edk/system/waiter.h ('k') | mojo/edk/system/waiter_test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/waiter.cc
diff --git a/mojo/edk/system/waiter.cc b/mojo/edk/system/waiter.cc
index 1ede9d071b7b6c2166b34e16f7f0ecca1c8bc44b..e254b5ca2be5b2b1febca388811ce658e72cbaa1 100644
--- a/mojo/edk/system/waiter.cc
+++ b/mojo/edk/system/waiter.cc
@@ -19,7 +19,7 @@ Waiter::Waiter()
initialized_(false),
#endif
awoken_(false),
- awake_result_(MOJO_RESULT_INTERNAL),
+ awake_reason_(AwakeReason::CANCELLED),
awake_context_(static_cast<uint64_t>(-1)) {
}
@@ -30,13 +30,12 @@ void Waiter::Init() {
initialized_ = true;
#endif
awoken_ = false;
- // NOTE(vtl): If performance ever becomes an issue, we can disable the setting
- // of |awake_result_| (except the first one in |Awake()|) in Release builds.
vardhan 2016/06/21 07:49:01 weird
- awake_result_ = MOJO_RESULT_INTERNAL;
}
// TODO(vtl): Fast-path the |deadline == 0| case?
-MojoResult Waiter::Wait(MojoDeadline deadline, uint64_t* context) {
+MojoResult Waiter::Wait(MojoDeadline deadline,
+ uint64_t* context,
+ HandleSignalsState* signals_state) {
MutexLocker locker(&mutex_);
#ifndef NDEBUG
@@ -47,10 +46,11 @@ MojoResult Waiter::Wait(MojoDeadline deadline, uint64_t* context) {
// Fast-path the already-awoken case:
if (awoken_) {
- DCHECK_NE(awake_result_, MOJO_RESULT_INTERNAL);
if (context)
*context = awake_context_;
- return awake_result_;
+ if (signals_state)
+ *signals_state = signals_state_;
+ return MojoResultForAwakeReason(awake_reason_);
}
if (deadline == MOJO_DEADLINE_INDEFINITE) {
@@ -85,10 +85,11 @@ MojoResult Waiter::Wait(MojoDeadline deadline, uint64_t* context) {
}
}
- DCHECK_NE(awake_result_, MOJO_RESULT_INTERNAL);
if (context)
*context = awake_context_;
- return awake_result_;
+ if (signals_state)
+ *signals_state = signals_state_;
+ return MojoResultForAwakeReason(awake_reason_);
}
bool Waiter::Awake(uint64_t context,
@@ -100,7 +101,8 @@ bool Waiter::Awake(uint64_t context,
return true;
awoken_ = true;
- awake_result_ = MojoResultForAwakeReason(reason);
+ awake_reason_ = reason;
+ signals_state_ = signals_state;
awake_context_ = context;
cv_.Signal();
// |cv_.Wait()|/|cv_.WaitWithTimeout()| will return after |mutex_| is
« no previous file with comments | « mojo/edk/system/waiter.h ('k') | mojo/edk/system/waiter_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698