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

Unified Diff: net/tools/quic/test_tools/server_thread.cc

Issue 132073002: Fix end_to_end_test performance regression caused by using mutexes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/test_tools/server_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/test_tools/server_thread.cc
diff --git a/net/tools/quic/test_tools/server_thread.cc b/net/tools/quic/test_tools/server_thread.cc
index ecc8ccdd61c8a2a80ef59763d122b51831760a39..e2b6506d17aae2931b1e2939b6017b021d348b78 100644
--- a/net/tools/quic/test_tools/server_thread.cc
+++ b/net/tools/quic/test_tools/server_thread.cc
@@ -15,33 +15,48 @@ ServerThread::ServerThread(IPEndPoint address,
const QuicVersionVector& supported_versions,
bool strike_register_no_startup_period)
: SimpleThread("server_thread"),
- listening_(true, false),
confirmed_(true, false),
+ pause_(true, false),
+ paused_(true, false),
+ resume_(true, false),
quit_(true, false),
server_(config, supported_versions),
address_(address),
- port_(0) {
+ port_(0),
+ initialized_(false) {
if (strike_register_no_startup_period) {
server_.SetStrikeRegisterNoStartupPeriod();
}
}
-ServerThread::~ServerThread() {
-}
+ServerThread::~ServerThread() {}
+
+void ServerThread::Initialize() {
+ if (initialized_) {
+ return;
+ }
-void ServerThread::Run() {
server_.Listen(address_);
port_lock_.Acquire();
port_ = server_.port();
port_lock_.Release();
- listening_.Signal();
+ initialized_ = true;
+}
+
+void ServerThread::Run() {
+ if (!initialized_) {
+ Initialize();
+ }
+
while (!quit_.IsSignaled()) {
- event_loop_mu_.Acquire();
+ if (pause_.IsSignaled() && !resume_.IsSignaled()) {
+ paused_.Signal();
+ resume_.Wait();
+ }
server_.WaitForEvents();
MaybeNotifyOfHandshakeConfirmation();
- event_loop_mu_.Release();
}
server_.Shutdown();
@@ -51,11 +66,7 @@ int ServerThread::GetPort() {
port_lock_.Acquire();
int rc = port_;
port_lock_.Release();
- return rc;
-}
-
-void ServerThread::WaitForServerStartup() {
- listening_.Wait();
+ return rc;
}
void ServerThread::WaitForCryptoHandshakeConfirmed() {
@@ -63,15 +74,21 @@ void ServerThread::WaitForCryptoHandshakeConfirmed() {
}
void ServerThread::Pause() {
- event_loop_mu_.Acquire();
+ DCHECK(!pause_.IsSignaled());
+ pause_.Signal();
+ paused_.Wait();
}
void ServerThread::Resume() {
- event_loop_mu_.AssertAcquired(); // Checks the calling thread only!
- event_loop_mu_.Release();
+ DCHECK(!resume_.IsSignaled());
+ DCHECK(pause_.IsSignaled());
+ resume_.Signal();
}
void ServerThread::Quit() {
+ if (pause_.IsSignaled() && !resume_.IsSignaled()) {
+ resume_.Signal();
+ }
quit_.Signal();
}
« no previous file with comments | « net/tools/quic/test_tools/server_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698