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

#include <thread_worker.h>

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

Public 成员函数

 ThreadWorker ()=default
 
 ~ThreadWorker ()
 
void Bind (const std::function< bool()> &func)
 
void Start ()
 
void WakeUp ()
 
void Join ()
 
void Release ()
 

详细描述

在文件 thread_worker.h27 行定义.

构造及析构函数说明

◆ ThreadWorker()

apollo::perception::lib::ThreadWorker::ThreadWorker ( )
default

◆ ~ThreadWorker()

apollo::perception::lib::ThreadWorker::~ThreadWorker ( )
inline

在文件 thread_worker.h30 行定义.

成员函数说明

◆ Bind()

void apollo::perception::lib::ThreadWorker::Bind ( const std::function< bool()> &  func)

在文件 thread_worker.cc22 行定义.

22 {
23 work_func_ = func;
24}

◆ Join()

void apollo::perception::lib::ThreadWorker::Join ( )

在文件 thread_worker.cc43 行定义.

43 {
44 std::unique_lock<std::mutex> lock(mutex_);
45 condition_.wait(lock, [&]() { return !work_flag_; });
46}

◆ Release()

void apollo::perception::lib::ThreadWorker::Release ( )

在文件 thread_worker.cc48 行定义.

48 {
49 if (thread_ptr_ == nullptr) {
50 return;
51 }
52 {
53 std::lock_guard<std::mutex> lock(mutex_);
54 work_flag_ = true;
55 exit_flag_ = true;
56 }
57 condition_.notify_one();
58 thread_ptr_->join();
59 thread_ptr_.reset(nullptr);
60}

◆ Start()

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

在文件 thread_worker.cc26 行定义.

26 {
27 if (thread_ptr_ == nullptr) {
28 thread_ptr_.reset(new std::thread(&ThreadWorker::Core, this));
29 }
30 std::lock_guard<std::mutex> lock(mutex_);
31 work_flag_ = false;
32 exit_flag_ = false;
33}

◆ WakeUp()

void apollo::perception::lib::ThreadWorker::WakeUp ( )

在文件 thread_worker.cc35 行定义.

35 {
36 {
37 std::lock_guard<std::mutex> lock(mutex_);
38 work_flag_ = true;
39 }
40 condition_.notify_one();
41}

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