| 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 fbb762ceaf04d84934949ed682fa125546cbfcaf..5d50565c851006f7bdee03f6ccb59f60f64e7d2e 100644
|
| --- a/net/tools/quic/test_tools/server_thread.cc
|
| +++ b/net/tools/quic/test_tools/server_thread.cc
|
| @@ -61,6 +61,7 @@ void ServerThread::Run() {
|
| resume_.Wait();
|
| }
|
| server_->WaitForEvents();
|
| + ExecuteScheduledActions();
|
| MaybeNotifyOfHandshakeConfirmation();
|
| }
|
|
|
| @@ -74,6 +75,12 @@ int ServerThread::GetPort() {
|
| return rc;
|
| }
|
|
|
| +void ServerThread::Schedule(std::function<void()> action) {
|
| + DCHECK(!quit_.IsSignaled());
|
| + base::AutoLock lock(scheduled_actions_lock_);
|
| + scheduled_actions_.push_back(std::move(action));
|
| +}
|
| +
|
| void ServerThread::WaitForCryptoHandshakeConfirmed() {
|
| confirmed_.Wait();
|
| }
|
| @@ -113,5 +120,17 @@ void ServerThread::MaybeNotifyOfHandshakeConfirmation() {
|
| }
|
| }
|
|
|
| +void ServerThread::ExecuteScheduledActions() {
|
| + std::deque<std::function<void()>> actions;
|
| + {
|
| + base::AutoLock lock(scheduled_actions_lock_);
|
| + actions.swap(scheduled_actions_);
|
| + }
|
| + while (!actions.empty()) {
|
| + actions.front()();
|
| + actions.pop_front();
|
| + }
|
| +}
|
| +
|
| } // namespace test
|
| } // namespace net
|
|
|