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

Side by Side Diff: mojo/public/cpp/system/wait.h

Issue 1825553002: Properly "handle" MOJO_RESULT_BUSY in a few flaces. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « mojo/public/cpp/system/tests/core_unittest.cc ('k') | mojo/public/cpp/utility/lib/run_loop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_ 5 #ifndef MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_
6 #define MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_ 6 #define MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <cstddef> 10 #include <cstddef>
(...skipping 26 matching lines...) Expand all
37 // A valid handle index is always returned if |WaitMany()| succeeds, but may 37 // A valid handle index is always returned if |WaitMany()| succeeds, but may
38 // or may not be returned if |WaitMany()| returns an error. Use this helper 38 // or may not be returned if |WaitMany()| returns an error. Use this helper
39 // function to check if |index| is a valid index into the handle array. 39 // function to check if |index| is a valid index into the handle array.
40 bool IsIndexValid() const { return index != kInvalidWaitManyIndexValue; } 40 bool IsIndexValid() const { return index != kInvalidWaitManyIndexValue; }
41 41
42 // The |signals_states| array is always returned by |WaitMany()| on success, 42 // The |signals_states| array is always returned by |WaitMany()| on success,
43 // but may or may not be returned if |WaitMany()| returns an error. Use this 43 // but may or may not be returned if |WaitMany()| returns an error. Use this
44 // helper function to check if |signals_states| holds valid data. 44 // helper function to check if |signals_states| holds valid data.
45 bool AreSignalsStatesValid() const { 45 bool AreSignalsStatesValid() const {
46 return result != MOJO_RESULT_INVALID_ARGUMENT && 46 return result != MOJO_RESULT_INVALID_ARGUMENT &&
47 result != MOJO_RESULT_RESOURCE_EXHAUSTED; 47 result != MOJO_RESULT_RESOURCE_EXHAUSTED &&
48 result != MOJO_RESULT_BUSY;
48 } 49 }
49 50
50 MojoResult result; 51 MojoResult result;
51 uint32_t index; 52 uint32_t index;
52 }; 53 };
53 54
54 // |HandleVectorType| and |FlagsVectorType| should be similar enough to 55 // |HandleVectorType| and |FlagsVectorType| should be similar enough to
55 // |std::vector<Handle>| and |std::vector<MojoHandleSignals>|, respectively: 56 // |std::vector<Handle>| and |std::vector<MojoHandleSignals>|, respectively:
56 // - They should have a (const) |size()| method that returns an unsigned type. 57 // - They should have a (const) |size()| method that returns an unsigned type.
57 // - They must provide contiguous storage, with access via (const) reference to 58 // - They must provide contiguous storage, with access via (const) reference to
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 const MojoHandleSignals& first_signals = signals[0]; 110 const MojoHandleSignals& first_signals = signals[0];
110 MojoResult result = MojoWaitMany( 111 MojoResult result = MojoWaitMany(
111 reinterpret_cast<const MojoHandle*>(&first_handle), &first_signals, 112 reinterpret_cast<const MojoHandle*>(&first_handle), &first_signals,
112 static_cast<uint32_t>(handles.size()), deadline, &result_index, nullptr); 113 static_cast<uint32_t>(handles.size()), deadline, &result_index, nullptr);
113 return WaitManyResult(result, result_index); 114 return WaitManyResult(result, result_index);
114 } 115 }
115 116
116 } // namespace mojo 117 } // namespace mojo
117 118
118 #endif // MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_ 119 #endif // MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/system/tests/core_unittest.cc ('k') | mojo/public/cpp/utility/lib/run_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698