#include <thread_worker.h>
◆ ThreadWorker()
| apollo::perception::lib::ThreadWorker::ThreadWorker |
( |
| ) |
|
|
default |
◆ ~ThreadWorker()
| apollo::perception::lib::ThreadWorker::~ThreadWorker |
( |
| ) |
|
|
inline |
◆ Bind()
| void apollo::perception::lib::ThreadWorker::Bind |
( |
const std::function< bool()> & |
func | ) |
|
◆ Join()
| void apollo::perception::lib::ThreadWorker::Join |
( |
| ) |
|
在文件 thread_worker.cc 第 43 行定义.
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.cc 第 48 行定义.
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.cc 第 26 行定义.
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.cc 第 35 行定义.
35 {
36 {
37 std::lock_guard<std::mutex> lock(mutex_);
38 work_flag_ = true;
39 }
40 condition_.notify_one();
41}
该类的文档由以下文件生成: