OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This tests the performance of the C API. | 5 // This tests the performance of the C API. |
6 | 6 |
7 #include "mojo/public/c/system/core.h" | 7 #include "mojo/public/c/system/core.h" |
8 | 8 |
9 #include <assert.h> | 9 #include <assert.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 for (;;) { | 79 for (;;) { |
80 uint32_t num_bytes = static_cast<uint32_t>(sizeof(buffer)); | 80 uint32_t num_bytes = static_cast<uint32_t>(sizeof(buffer)); |
81 MojoResult result = MojoReadMessage(handle_, buffer, &num_bytes, NULL, | 81 MojoResult result = MojoReadMessage(handle_, buffer, &num_bytes, NULL, |
82 NULL, MOJO_READ_MESSAGE_FLAG_NONE); | 82 NULL, MOJO_READ_MESSAGE_FLAG_NONE); |
83 if (result == MOJO_RESULT_OK) { | 83 if (result == MOJO_RESULT_OK) { |
84 num_reads_++; | 84 num_reads_++; |
85 continue; | 85 continue; |
86 } | 86 } |
87 | 87 |
88 if (result == MOJO_RESULT_SHOULD_WAIT) { | 88 if (result == MOJO_RESULT_SHOULD_WAIT) { |
89 result = MojoWait(handle_, MOJO_WAIT_FLAG_READABLE, | 89 result = MojoWait(handle_, MOJO_HANDLE_SIGNAL_READABLE, |
90 MOJO_DEADLINE_INDEFINITE); | 90 MOJO_DEADLINE_INDEFINITE); |
91 if (result == MOJO_RESULT_OK) { | 91 if (result == MOJO_RESULT_OK) { |
92 // Go to the top of the loop to read again. | 92 // Go to the top of the loop to read again. |
93 continue; | 93 continue; |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 // We failed to read and possibly failed to wait. | 97 // We failed to read and possibly failed to wait. |
98 // Either |handle_| or its peer was closed. | 98 // Either |handle_| or its peer was closed. |
99 assert(result == MOJO_RESULT_INVALID_ARGUMENT || | 99 assert(result == MOJO_RESULT_INVALID_ARGUMENT || |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 DoMessagePipeThreadedTest(1u, 1u, 10000u); | 328 DoMessagePipeThreadedTest(1u, 1u, 10000u); |
329 | 329 |
330 DoMessagePipeThreadedTest(3u, 3u, 10u); | 330 DoMessagePipeThreadedTest(3u, 3u, 10u); |
331 // 100 was done above. | 331 // 100 was done above. |
332 DoMessagePipeThreadedTest(3u, 3u, 1000u); | 332 DoMessagePipeThreadedTest(3u, 3u, 1000u); |
333 DoMessagePipeThreadedTest(3u, 3u, 10000u); | 333 DoMessagePipeThreadedTest(3u, 3u, 10000u); |
334 } | 334 } |
335 #endif // !defined(WIN32) | 335 #endif // !defined(WIN32) |
336 | 336 |
337 } // namespace | 337 } // namespace |
OLD | NEW |