Apollo 11.0
自动驾驶开放平台
apollo::perception::lib::ThreadPoolWorker类 参考

#include <thread_pool.h>

类 apollo::perception::lib::ThreadPoolWorker 继承关系图:
apollo::perception::lib::ThreadPoolWorker 的协作图:

Public 成员函数

 ThreadPoolWorker (ThreadPool *thread_pool)
 
virtual ~ThreadPoolWorker ()
 
 ThreadPoolWorker (const ThreadPoolWorker &)=delete
 
ThreadPoolWorkeroperator= (const ThreadPoolWorker &)=delete
 
- Public 成员函数 继承自 apollo::perception::lib::Thread
 Thread (bool joinable=false, const std::string &name="Thread")
 
pthread_t tid () const
 
void set_joinable (bool joinable)
 
void Start ()
 
void Join ()
 
bool IsAlive ()
 
std::string get_thread_name () const
 
void set_thread_name (const std::string &name)
 
 Thread (const Thread &)=delete
 
Threadoperator= (const Thread &)=delete
 

Protected 成员函数

void Run () override
 

额外继承的成员函数

- 静态 Protected 成员函数 继承自 apollo::perception::lib::Thread
static void * ThreadRunner (void *arg)
 
- Protected 属性 继承自 apollo::perception::lib::Thread
pthread_t tid_
 
bool started_
 
bool joinable_
 
std::string thread_name_
 

详细描述

在文件 thread_pool.h63 行定义.

构造及析构函数说明

◆ ThreadPoolWorker() [1/2]

apollo::perception::lib::ThreadPoolWorker::ThreadPoolWorker ( ThreadPool thread_pool)
inlineexplicit

在文件 thread_pool.h65 行定义.

66 : Thread(true, "ThreadPoolWorker"), thread_pool_(thread_pool) {}
Thread(bool joinable=false, const std::string &name="Thread")
Definition thread.h:26

◆ ~ThreadPoolWorker()

virtual apollo::perception::lib::ThreadPoolWorker::~ThreadPoolWorker ( )
inlinevirtual

在文件 thread_pool.h68 行定义.

68{}

◆ ThreadPoolWorker() [2/2]

apollo::perception::lib::ThreadPoolWorker::ThreadPoolWorker ( const ThreadPoolWorker )
delete

成员函数说明

◆ operator=()

ThreadPoolWorker & apollo::perception::lib::ThreadPoolWorker::operator= ( const ThreadPoolWorker )
delete

◆ Run()

void apollo::perception::lib::ThreadPoolWorker::Run ( )
overrideprotectedvirtual

实现了 apollo::perception::lib::Thread.

在文件 thread_pool.cc69 行定义.

69 {
70 while (true) {
71 Closure *closure = nullptr;
72 thread_pool_->task_queue_.Pop(&closure);
73 if (closure == nullptr) {
74 break;
75 }
76
77 {
78 MutexLock lock(&(thread_pool_->mutex_));
79 --(thread_pool_->num_available_workers_);
80 }
81
82 closure->Run();
83
84 {
85 MutexLock lock(&(thread_pool_->mutex_));
86 ++(thread_pool_->num_available_workers_);
87 }
88 }
89}

该类的文档由以下文件生成: