OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_HANDLE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ |
6 #define MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ | 6 #define MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ |
7 | 7 |
8 #include <assert.h> | 8 #include <assert.h> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // constant can be converted to |std::nullptr_t| (which is a typedef for | 294 // constant can be converted to |std::nullptr_t| (which is a typedef for |
295 // |decltype(nullptr)|). The opposite direction is not allowed. | 295 // |decltype(nullptr)|). The opposite direction is not allowed. |
296 template <class HandleVectorType, class FlagsVectorType> | 296 template <class HandleVectorType, class FlagsVectorType> |
297 inline WaitManyResult WaitMany(const HandleVectorType& handles, | 297 inline WaitManyResult WaitMany(const HandleVectorType& handles, |
298 const FlagsVectorType& signals, | 298 const FlagsVectorType& signals, |
299 MojoDeadline deadline, | 299 MojoDeadline deadline, |
300 decltype(nullptr) signals_states) { | 300 decltype(nullptr) signals_states) { |
301 if (signals.size() != handles.size()) | 301 if (signals.size() != handles.size()) |
302 return WaitManyResult(MOJO_RESULT_INVALID_ARGUMENT); | 302 return WaitManyResult(MOJO_RESULT_INVALID_ARGUMENT); |
303 if (handles.size() >= kInvalidWaitManyIndexValue) | 303 if (handles.size() >= kInvalidWaitManyIndexValue) |
304 return WaitManyResult(MOJO_RESULT_OUT_OF_RANGE); | 304 return WaitManyResult(MOJO_RESULT_RESOURCE_EXHAUSTED); |
305 | 305 |
306 if (handles.size() == 0) { | 306 if (handles.size() == 0) { |
307 return WaitManyResult( | 307 return WaitManyResult( |
308 MojoNewWaitMany(nullptr, nullptr, 0, deadline, nullptr, nullptr)); | 308 MojoNewWaitMany(nullptr, nullptr, 0, deadline, nullptr, nullptr)); |
309 } | 309 } |
310 | 310 |
311 uint32_t result_index = kInvalidWaitManyIndexValue; | 311 uint32_t result_index = kInvalidWaitManyIndexValue; |
312 const Handle& first_handle = handles[0]; | 312 const Handle& first_handle = handles[0]; |
313 const MojoHandleSignals& first_signals = signals[0]; | 313 const MojoHandleSignals& first_signals = signals[0]; |
314 MojoResult result = MojoNewWaitMany( | 314 MojoResult result = MojoNewWaitMany( |
(...skipping 15 matching lines...) Expand all Loading... |
330 } | 330 } |
331 | 331 |
332 // Strict weak ordering, so that |Handle|s can be used as keys in |std::map|s, | 332 // Strict weak ordering, so that |Handle|s can be used as keys in |std::map|s, |
333 inline bool operator<(const Handle a, const Handle b) { | 333 inline bool operator<(const Handle a, const Handle b) { |
334 return a.value() < b.value(); | 334 return a.value() < b.value(); |
335 } | 335 } |
336 | 336 |
337 } // namespace mojo | 337 } // namespace mojo |
338 | 338 |
339 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ | 339 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ |
OLD | NEW |