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

#include <thread_pool.h>

apollo::perception::lib::ThreadPool 的协作图:

Public 成员函数

 ThreadPool (int num_workers)
 
 ~ThreadPool ()
 
void Start ()
 
void Add (google::protobuf::Closure *closure)
 
void Add (const std::vector< google::protobuf::Closure * > &closures)
 
int num_workers () const
 
int num_available_workers () const
 
 ThreadPool (const ThreadPool &)=delete
 
ThreadPooloperator= (const ThreadPool &)=delete
 

友元

class ThreadPoolWorker
 

详细描述

在文件 thread_pool.h33 行定义.

构造及析构函数说明

◆ ThreadPool() [1/2]

apollo::perception::lib::ThreadPool::ThreadPool ( int  num_workers)
explicit

在文件 thread_pool.cc27 行定义.

28 : num_workers_(num_workers),
29 num_available_workers_(num_workers),
30 task_queue_(num_workers),
31 started_(false) {
32 workers_.reserve(num_workers_);
33 for (int idx = 0; idx < num_workers_; ++idx) {
34 ThreadPoolWorker *worker = new ThreadPoolWorker(this);
35 workers_.push_back(worker);
36 }
37}

◆ ~ThreadPool()

apollo::perception::lib::ThreadPool::~ThreadPool ( )

在文件 thread_pool.cc39 行定义.

39 {
40 if (!started_) {
41 return;
42 }
43
44 for (int idx = 0; idx < num_workers_; ++idx) {
45 Add(NULL);
46 }
47
48 for (int idx = 0; idx < num_workers_; ++idx) {
49 workers_[idx]->Join();
50 delete workers_[idx];
51 }
52}
void Add(google::protobuf::Closure *closure)

◆ ThreadPool() [2/2]

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

成员函数说明

◆ Add() [1/2]

void apollo::perception::lib::ThreadPool::Add ( const std::vector< google::protobuf::Closure * > &  closures)

◆ Add() [2/2]

void apollo::perception::lib::ThreadPool::Add ( google::protobuf::Closure *  closure)

◆ num_available_workers()

int apollo::perception::lib::ThreadPool::num_available_workers ( ) const
inline

在文件 thread_pool.h46 行定义.

46{ return num_available_workers_; }

◆ num_workers()

int apollo::perception::lib::ThreadPool::num_workers ( ) const
inline

在文件 thread_pool.h44 行定义.

44{ return num_workers_; }

◆ operator=()

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

◆ Start()

void apollo::perception::lib::ThreadPool::Start ( )

在文件 thread_pool.cc54 行定义.

54 {
55 for (int idx = 0; idx < num_workers_; ++idx) {
56 workers_[idx]->Start();
57 }
58 started_ = true;
59}

友元及相关函数文档

◆ ThreadPoolWorker

friend class ThreadPoolWorker
friend

在文件 thread_pool.h52 行定义.


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