cartographer源码分析(10)-common-thread_pool.h

本文主要分析cartographer开源项目中common模块的thread_pool.h源码,该文件涉及线程池的实现,可在指定链接下载源码进行深入学习。

源码可在https://github.com/learnmoreonce/SLAM 下载


文件:common/thread_pool.h



#ifndef CARTOGRAPHER_COMMON_THREAD_POOL_H_
#define CARTOGRAPHER_COMMON_THREAD_POOL_H_

#include <deque>
#include <functional>
#include <thread>
#include <vector>

#include "cartographer/common/mutex.h"

namespace cartographer {
namespace common {

/*
ThreadPool 是对c++11 thread的封装.
ThreadPool是线程数量固定的线程池,不可拷贝 和复制.

1,构造函数ThreadPool(int num_threads) 初始化一个线程数量固定的线程池。
2,Schedule(std::function<void()> work_item)添加想要ThreadPool执行的函数,
   std::thread会在线程后台依次排队执行相关函数.
3,数据成员pool_是具体的线程,work_queue_是待执行的函数队列。


*/
// A fixed number of threads working on a work queue of work items. Adding a
// new work item does not block, and will be executed by a background thread
// eventually. The queue must be empty before calling the destructor. The thread
// pool will th
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值