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

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

Issue 2110103002: Make MojoWaitMany() accept zero handles. (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 | « no previous file | mojo/edk/system/core_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/core.cc
diff --git a/mojo/edk/system/core.cc b/mojo/edk/system/core.cc
index d38457c4c1adceabc275c125ea6a3fc5e6338e13..f077c7585b8a2626e8aebfea0ad8df678f54ba25 100644
--- a/mojo/edk/system/core.cc
+++ b/mojo/edk/system/core.cc
@@ -257,17 +257,18 @@ MojoResult Core::WaitMany(UserPointer<const MojoHandle> handles,
MojoDeadline deadline,
UserPointer<uint32_t> result_index,
UserPointer<MojoHandleSignalsState> signals_states) {
- if (num_handles < 1)
- return MOJO_RESULT_INVALID_ARGUMENT;
if (num_handles > GetConfiguration().max_wait_many_num_handles)
return MOJO_RESULT_RESOURCE_EXHAUSTED;
+ uint64_t index = static_cast<uint64_t>(-1);
+ if (num_handles == 0u)
+ return WaitManyInternal(nullptr, nullptr, 0u, deadline, &index, nullptr);
+
UserPointer<const MojoHandle>::Reader handles_reader(handles, num_handles);
UserPointer<const MojoHandleSignals>::Reader signals_reader(signals,
num_handles);
- uint64_t index = static_cast<uint64_t>(-1);
MojoResult result;
- if (signals_states.IsNull()) {
+ if (signals_states.IsNull() || num_handles == 0u) {
result = WaitManyInternal(handles_reader.GetPointer(),
signals_reader.GetPointer(), num_handles,
deadline, &index, nullptr);
@@ -842,7 +843,6 @@ MojoResult Core::WaitManyInternal(const MojoHandle* handles,
MojoDeadline deadline,
uint64_t* result_index,
HandleSignalsState* signals_states) {
- DCHECK_GT(num_handles, 0u);
DCHECK_EQ(*result_index, static_cast<uint64_t>(-1));
DispatcherVector dispatchers;
« no previous file with comments | « no previous file | mojo/edk/system/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698