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

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

Issue 2072353002: Give AwakableList's wake-up method the old state in addition to the new state. (Closed) Base URL: https://github.com/domokit/mojo.git@master
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/data_pipe.cc ('k') | mojo/edk/system/mock_simple_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/local_message_pipe_endpoint.cc
diff --git a/mojo/edk/system/local_message_pipe_endpoint.cc b/mojo/edk/system/local_message_pipe_endpoint.cc
index 276a009df0cc8490a854a99114d377eec8ad0e5f..be7f0c5011254923ef0ead9bd03c28e432fa385c 100644
--- a/mojo/edk/system/local_message_pipe_endpoint.cc
+++ b/mojo/edk/system/local_message_pipe_endpoint.cc
@@ -39,7 +39,7 @@ bool LocalMessagePipeEndpoint::OnPeerClose() {
HandleSignalsState new_state = GetHandleSignalsState();
if (!new_state.equals(old_state))
- awakable_list_.AwakeForStateChange(new_state);
+ awakable_list_.OnStateChange(old_state, new_state);
return true;
}
@@ -49,10 +49,12 @@ void LocalMessagePipeEndpoint::EnqueueMessage(
DCHECK(is_open_);
DCHECK(is_peer_open_);
- bool was_empty = message_queue_.IsEmpty();
+ HandleSignalsState old_state = GetHandleSignalsState();
message_queue_.AddMessage(std::move(message));
- if (was_empty)
- awakable_list_.AwakeForStateChange(GetHandleSignalsState());
+ HandleSignalsState new_state = GetHandleSignalsState();
+
+ if (!new_state.equals(old_state))
+ awakable_list_.OnStateChange(old_state, new_state);
}
void LocalMessagePipeEndpoint::Close() {
@@ -115,14 +117,12 @@ MojoResult LocalMessagePipeEndpoint::ReadMessage(
message = nullptr;
if (enough_space || (flags & MOJO_READ_MESSAGE_FLAG_MAY_DISCARD)) {
+ HandleSignalsState old_state = GetHandleSignalsState();
message_queue_.DiscardMessage();
+ HandleSignalsState new_state = GetHandleSignalsState();
- // Now it's empty, thus no longer readable.
- if (message_queue_.IsEmpty()) {
- // It's currently not possible to wait for non-readability, but we should
- // do the state change anyway.
- awakable_list_.AwakeForStateChange(GetHandleSignalsState());
- }
+ if (!new_state.equals(old_state))
+ awakable_list_.OnStateChange(old_state, new_state);
}
if (!enough_space)
« no previous file with comments | « mojo/edk/system/data_pipe.cc ('k') | mojo/edk/system/mock_simple_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698