xref: /aosp_15_r20/external/cronet/base/task/thread_pool/service_thread.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_TASK_THREAD_POOL_SERVICE_THREAD_H_
6 #define BASE_TASK_THREAD_POOL_SERVICE_THREAD_H_
7 
8 #include "base/base_export.h"
9 #include "base/threading/thread.h"
10 
11 namespace base {
12 namespace internal {
13 
14 // The ThreadPool's ServiceThread is a mostly idle thread that is responsible
15 // for handling async events (e.g. delayed tasks and async I/O). Its role is to
16 // merely forward such events to their destination (hence staying mostly idle
17 // and highly responsive).
18 // It aliases Thread::Run() to enforce that ServiceThread::Run() be on the stack
19 // and make it easier to identify the service thread in stack traces.
20 class BASE_EXPORT ServiceThread : public Thread {
21  public:
22   ServiceThread();
23 
24   ServiceThread(const ServiceThread&) = delete;
25   ServiceThread& operator=(const ServiceThread&) = delete;
26   ~ServiceThread() override = default;
27 
28  private:
29   // Thread:
30   void Run(RunLoop* run_loop) override;
31 };
32 
33 }  // namespace internal
34 }  // namespace base
35 
36 #endif  // BASE_TASK_THREAD_POOL_SERVICE_THREAD_H_
37