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

Side by Side Diff: mojo/edk/system/message_pipe_perftest.cc

Issue 2741033003: Mojo EDK: Introduce MojoQueryHandleSignalsState API (Closed)
Patch Set: fix stupid bad DCHECK Created 3 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/edk/system/handle_signals_state.h ('k') | mojo/edk/system/message_pipe_unittest.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 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 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 29 matching lines...) Expand all
40 read_buffer_.resize(message_size * 2); 40 read_buffer_.resize(message_size * 2);
41 } 41 }
42 42
43 protected: 43 protected:
44 void WriteWaitThenRead(MojoHandle mp) { 44 void WriteWaitThenRead(MojoHandle mp) {
45 CHECK_EQ(MojoWriteMessage(mp, payload_.data(), 45 CHECK_EQ(MojoWriteMessage(mp, payload_.data(),
46 static_cast<uint32_t>(payload_.size()), nullptr, 46 static_cast<uint32_t>(payload_.size()), nullptr,
47 0, MOJO_WRITE_MESSAGE_FLAG_NONE), 47 0, MOJO_WRITE_MESSAGE_FLAG_NONE),
48 MOJO_RESULT_OK); 48 MOJO_RESULT_OK);
49 HandleSignalsState hss; 49 HandleSignalsState hss;
50 CHECK_EQ(MojoWait(mp, MOJO_HANDLE_SIGNAL_READABLE, MOJO_DEADLINE_INDEFINITE, 50 CHECK_EQ(WaitForSignals(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss),
51 &hss),
52 MOJO_RESULT_OK); 51 MOJO_RESULT_OK);
53 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer_.size()); 52 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer_.size());
54 CHECK_EQ(MojoReadMessage(mp, &read_buffer_[0], &read_buffer_size, nullptr, 53 CHECK_EQ(MojoReadMessage(mp, &read_buffer_[0], &read_buffer_size, nullptr,
55 nullptr, MOJO_READ_MESSAGE_FLAG_NONE), 54 nullptr, MOJO_READ_MESSAGE_FLAG_NONE),
56 MOJO_RESULT_OK); 55 MOJO_RESULT_OK);
57 CHECK_EQ(read_buffer_size, static_cast<uint32_t>(payload_.size())); 56 CHECK_EQ(read_buffer_size, static_cast<uint32_t>(payload_.size()));
58 } 57 }
59 58
60 void SendQuitMessage(MojoHandle mp) { 59 void SendQuitMessage(MojoHandle mp) {
61 CHECK_EQ(MojoWriteMessage(mp, "", 0, nullptr, 0, 60 CHECK_EQ(MojoWriteMessage(mp, "", 0, nullptr, 0,
(...skipping 29 matching lines...) Expand all
91 90
92 SendQuitMessage(mp); 91 SendQuitMessage(mp);
93 } 92 }
94 93
95 static int RunPingPongClient(MojoHandle mp) { 94 static int RunPingPongClient(MojoHandle mp) {
96 std::string buffer(1000000, '\0'); 95 std::string buffer(1000000, '\0');
97 int rv = 0; 96 int rv = 0;
98 while (true) { 97 while (true) {
99 // Wait for our end of the message pipe to be readable. 98 // Wait for our end of the message pipe to be readable.
100 HandleSignalsState hss; 99 HandleSignalsState hss;
101 MojoResult result = 100 MojoResult result = WaitForSignals(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss);
102 MojoWait(mp, MOJO_HANDLE_SIGNAL_READABLE,
103 MOJO_DEADLINE_INDEFINITE, &hss);
104 if (result != MOJO_RESULT_OK) { 101 if (result != MOJO_RESULT_OK) {
105 rv = result; 102 rv = result;
106 break; 103 break;
107 } 104 }
108 105
109 uint32_t read_size = static_cast<uint32_t>(buffer.size()); 106 uint32_t read_size = static_cast<uint32_t>(buffer.size());
110 CHECK_EQ(MojoReadMessage(mp, &buffer[0], 107 CHECK_EQ(MojoReadMessage(mp, &buffer[0],
111 &read_size, nullptr, 108 &read_size, nullptr,
112 0, MOJO_READ_MESSAGE_FLAG_NONE), 109 0, MOJO_READ_MESSAGE_FLAG_NONE),
113 MOJO_RESULT_OK); 110 MOJO_RESULT_OK);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // number of messages has been sent. 158 // number of messages has been sent.
162 TEST_F(MessagePipePerfTest, MultiprocessPingPong) { 159 TEST_F(MessagePipePerfTest, MultiprocessPingPong) {
163 RUN_CHILD_ON_PIPE(PingPongClient, h) 160 RUN_CHILD_ON_PIPE(PingPongClient, h)
164 RunPingPongServer(h); 161 RunPingPongServer(h);
165 END_CHILD() 162 END_CHILD()
166 } 163 }
167 164
168 } // namespace 165 } // namespace
169 } // namespace edk 166 } // namespace edk
170 } // namespace mojo 167 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/handle_signals_state.h ('k') | mojo/edk/system/message_pipe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698