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

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

Issue 2750273002: Revert of Mojo EDK: Introduce MojoQueryHandleSignalsState API (Closed)
Patch Set: 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(WaitForSignals(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss), 50 CHECK_EQ(MojoWait(mp, MOJO_HANDLE_SIGNAL_READABLE, MOJO_DEADLINE_INDEFINITE,
51 &hss),
51 MOJO_RESULT_OK); 52 MOJO_RESULT_OK);
52 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer_.size()); 53 uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer_.size());
53 CHECK_EQ(MojoReadMessage(mp, &read_buffer_[0], &read_buffer_size, nullptr, 54 CHECK_EQ(MojoReadMessage(mp, &read_buffer_[0], &read_buffer_size, nullptr,
54 nullptr, MOJO_READ_MESSAGE_FLAG_NONE), 55 nullptr, MOJO_READ_MESSAGE_FLAG_NONE),
55 MOJO_RESULT_OK); 56 MOJO_RESULT_OK);
56 CHECK_EQ(read_buffer_size, static_cast<uint32_t>(payload_.size())); 57 CHECK_EQ(read_buffer_size, static_cast<uint32_t>(payload_.size()));
57 } 58 }
58 59
59 void SendQuitMessage(MojoHandle mp) { 60 void SendQuitMessage(MojoHandle mp) {
60 CHECK_EQ(MojoWriteMessage(mp, "", 0, nullptr, 0, 61 CHECK_EQ(MojoWriteMessage(mp, "", 0, nullptr, 0,
(...skipping 29 matching lines...) Expand all
90 91
91 SendQuitMessage(mp); 92 SendQuitMessage(mp);
92 } 93 }
93 94
94 static int RunPingPongClient(MojoHandle mp) { 95 static int RunPingPongClient(MojoHandle mp) {
95 std::string buffer(1000000, '\0'); 96 std::string buffer(1000000, '\0');
96 int rv = 0; 97 int rv = 0;
97 while (true) { 98 while (true) {
98 // Wait for our end of the message pipe to be readable. 99 // Wait for our end of the message pipe to be readable.
99 HandleSignalsState hss; 100 HandleSignalsState hss;
100 MojoResult result = WaitForSignals(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss); 101 MojoResult result =
102 MojoWait(mp, MOJO_HANDLE_SIGNAL_READABLE,
103 MOJO_DEADLINE_INDEFINITE, &hss);
101 if (result != MOJO_RESULT_OK) { 104 if (result != MOJO_RESULT_OK) {
102 rv = result; 105 rv = result;
103 break; 106 break;
104 } 107 }
105 108
106 uint32_t read_size = static_cast<uint32_t>(buffer.size()); 109 uint32_t read_size = static_cast<uint32_t>(buffer.size());
107 CHECK_EQ(MojoReadMessage(mp, &buffer[0], 110 CHECK_EQ(MojoReadMessage(mp, &buffer[0],
108 &read_size, nullptr, 111 &read_size, nullptr,
109 0, MOJO_READ_MESSAGE_FLAG_NONE), 112 0, MOJO_READ_MESSAGE_FLAG_NONE),
110 MOJO_RESULT_OK); 113 MOJO_RESULT_OK);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // number of messages has been sent. 161 // number of messages has been sent.
159 TEST_F(MessagePipePerfTest, MultiprocessPingPong) { 162 TEST_F(MessagePipePerfTest, MultiprocessPingPong) {
160 RUN_CHILD_ON_PIPE(PingPongClient, h) 163 RUN_CHILD_ON_PIPE(PingPongClient, h)
161 RunPingPongServer(h); 164 RunPingPongServer(h);
162 END_CHILD() 165 END_CHILD()
163 } 166 }
164 167
165 } // namespace 168 } // namespace
166 } // namespace edk 169 } // namespace edk
167 } // namespace mojo 170 } // 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