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

Side by Side Diff: net/tools/quic/test_tools/server_thread.cc

Issue 2561913003: Create a QUIC wrapper around a mutex and a mutex lock. (Closed)
Patch Set: fix Created 4 years 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 | « net/tools/quic/test_tools/server_thread.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "net/tools/quic/test_tools/server_thread.h" 5 #include "net/tools/quic/test_tools/server_thread.h"
6 6
7 #include "net/quic/test_tools/crypto_test_utils.h" 7 #include "net/quic/test_tools/crypto_test_utils.h"
8 #include "net/tools/quic/quic_dispatcher.h" 8 #include "net/tools/quic/quic_dispatcher.h"
9 #include "net/tools/quic/test_tools/quic_server_peer.h" 9 #include "net/tools/quic/test_tools/quic_server_peer.h"
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 int ServerThread::GetPort() { 65 int ServerThread::GetPort() {
66 port_lock_.Acquire(); 66 port_lock_.Acquire();
67 int rc = port_; 67 int rc = port_;
68 port_lock_.Release(); 68 port_lock_.Release();
69 return rc; 69 return rc;
70 } 70 }
71 71
72 void ServerThread::Schedule(std::function<void()> action) { 72 void ServerThread::Schedule(std::function<void()> action) {
73 DCHECK(!quit_.IsSignaled()); 73 DCHECK(!quit_.IsSignaled());
74 base::AutoLock lock(scheduled_actions_lock_); 74 QuicWriterMutexLock lock(&scheduled_actions_lock_);
75 scheduled_actions_.push_back(std::move(action)); 75 scheduled_actions_.push_back(std::move(action));
76 } 76 }
77 77
78 void ServerThread::WaitForCryptoHandshakeConfirmed() { 78 void ServerThread::WaitForCryptoHandshakeConfirmed() {
79 confirmed_.Wait(); 79 confirmed_.Wait();
80 } 80 }
81 81
82 void ServerThread::Pause() { 82 void ServerThread::Pause() {
83 DCHECK(!pause_.IsSignaled()); 83 DCHECK(!pause_.IsSignaled());
84 pause_.Signal(); 84 pause_.Signal();
(...skipping 25 matching lines...) Expand all
110 } 110 }
111 QuicSession* session = dispatcher->session_map().begin()->second.get(); 111 QuicSession* session = dispatcher->session_map().begin()->second.get();
112 if (session->IsCryptoHandshakeConfirmed()) { 112 if (session->IsCryptoHandshakeConfirmed()) {
113 confirmed_.Signal(); 113 confirmed_.Signal();
114 } 114 }
115 } 115 }
116 116
117 void ServerThread::ExecuteScheduledActions() { 117 void ServerThread::ExecuteScheduledActions() {
118 std::deque<std::function<void()>> actions; 118 std::deque<std::function<void()>> actions;
119 { 119 {
120 base::AutoLock lock(scheduled_actions_lock_); 120 QuicWriterMutexLock lock(&scheduled_actions_lock_);
121 actions.swap(scheduled_actions_); 121 actions.swap(scheduled_actions_);
122 } 122 }
123 while (!actions.empty()) { 123 while (!actions.empty()) {
124 actions.front()(); 124 actions.front()();
125 actions.pop_front(); 125 actions.pop_front();
126 } 126 }
127 } 127 }
128 128
129 } // namespace test 129 } // namespace test
130 } // namespace net 130 } // namespace net
OLDNEW
« 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