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

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

Issue 2060943007: Make it possible to remove an Awakable with a specific "context" from a Dispatcher. (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/dispatcher.h ('k') | mojo/edk/system/local_message_pipe_endpoint.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/dispatcher.cc
diff --git a/mojo/edk/system/dispatcher.cc b/mojo/edk/system/dispatcher.cc
index 11f73e244afac2731df7d1f113d5ea9f9f048927..7d9741af920030dce0168643a7d23c77743ad996 100644
--- a/mojo/edk/system/dispatcher.cc
+++ b/mojo/edk/system/dispatcher.cc
@@ -337,15 +337,28 @@ MojoResult Dispatcher::AddAwakableUnconditional(
}
void Dispatcher::RemoveAwakable(Awakable* awakable,
- HandleSignalsState* handle_signals_state) {
+ HandleSignalsState* signals_state) {
MutexLocker locker(&mutex_);
if (is_closed_) {
- if (handle_signals_state)
- *handle_signals_state = HandleSignalsState();
+ if (signals_state)
+ *signals_state = HandleSignalsState();
+ return;
+ }
+
+ RemoveAwakableImplNoLock(awakable, signals_state);
+}
+
+void Dispatcher::RemoveAwakableWithContext(Awakable* awakable,
+ uint64_t context,
+ HandleSignalsState* signals_state) {
+ MutexLocker locker(&mutex_);
+ if (is_closed_) {
+ if (signals_state)
+ *signals_state = HandleSignalsState();
return;
}
- RemoveAwakableImplNoLock(awakable, handle_signals_state);
+ RemoveAwakableWithContextImplNoLock(awakable, context, signals_state);
}
Dispatcher::Dispatcher() : is_closed_(false) {}
@@ -579,6 +592,18 @@ void Dispatcher::RemoveAwakableImplNoLock(Awakable* /*awakable*/,
*signals_state = HandleSignalsState();
}
+void Dispatcher::RemoveAwakableWithContextImplNoLock(
+ Awakable* /*awakable*/,
+ uint64_t /*context*/,
+ HandleSignalsState* signals_state) {
+ mutex_.AssertHeld();
+ DCHECK(!is_closed_);
+ // By default, waiting isn't supported. Only dispatchers that can be waited on
+ // will do something nontrivial.
+ if (signals_state)
+ *signals_state = HandleSignalsState();
+}
+
void Dispatcher::StartSerializeImplNoLock(Channel* /*channel*/,
size_t* max_size,
size_t* max_platform_handles) {
« no previous file with comments | « mojo/edk/system/dispatcher.h ('k') | mojo/edk/system/local_message_pipe_endpoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698