// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef REMOTING_BASE_AUTO_THREAD_H_ #define REMOTING_BASE_AUTO_THREAD_H_ #include <string> #include "base/functional/callback_forward.h" #include "base/memory/raw_ptr.h" #include "base/message_loop/message_pump_type.h" #include "base/threading/platform_thread.h" #include "base/threading/thread_checker.h" #include "build/build_config.h" #include "remoting/base/auto_thread_task_runner.h" namespace remoting { // Thread implementation that runs a MessageLoop on a new thread, and manages // the lifetime of the MessageLoop and thread by tracking references to the // thread's TaskRunner. The caller passes the thread's TaskRunner to each // object that needs to run code on the thread, and when no references to the // TaskRunner remain, the thread will exit. When the caller destroys this // object they will be blocked until the thread exits. // All pending tasks queued on the thread's message loop will run to completion // before the thread is terminated. // // After the thread is stopped, the destruction sequence is: // // (1) Thread::CleanUp() // (2) MessageLoop::~MessageLoop // (3.b) CurrentThread::DestructionObserver::WillDestroyCurrentMessageLoop class AutoThread : base::PlatformThread::Delegate { … }; } // namespace remoting #endif // REMOTING_BASE_AUTO_THREAD_H_