C++队列模板使用std::queue
来源:互联网 发布:生化危机剧情 知乎 编辑:程序博客网 时间:2024/06/15 19:07
#ifndef _TASK_QUEUE_H_#define _TASK_QUEUE_H_#include <string>#include <queue>#include <boost/thread.hpp>template<class T>class TaskQueue {public: TaskQueue(){ queue_.clear(); } virtual ~TaskQueue(){ }; /** * @Appends the task to the queue * @param the task object **/ virtual void append(const T& _t){ thr_lck lck(mtx_); queue_.push(_t); } /** * @Return the current size of the queue * @returns the queue size **/ virtual size_t queueSize() const { thr_lck lck(mtx_); return queue_.size(); } /** * @Return the queue * @returns the message queue **/ virtual bool empty() { thr_lck lck(mtx_); return queue_.empty(); } /** * @Return the queue * @returns the message queue **/ virtual std::queue<T>& getQueue() { thr_lck lck(mtx_); return queue_; } /** * @Return the queue * @returns the message queue **/ virtual const std::queue<T>& getQueue() const { thr_lck lck(mtx_); return queue_; } /** * @Return the oldest task from the queue * @returns the front task **/ virtual T front() { thr_lck lck(mtx_); T message; if (!queue_.empty()) { message = queue_.front(); } return message; } /** * @Pop the oldest task from the front of the queue. * @returns the oldest task **/ virtual T popMessage(){ thr_lck lck(mtx_); T message; if (!queue_.empty()) { message = queue_.front(); queue_.pop(); } return message; }protected: typedef std::queue<T> task_queue; task_queue queue_; typedef boost::mutex::scoped_lock thr_lck; boost::mutex mtx_;};#endif
0 0
- C++队列模板使用std::queue
- 模板队列Queue类
- C++队列模板queue
- C++/C++11中std::queue的使用
- 【day0414 C++】queue 队列的使用
- queue-c链式队列
- C++_队列(Queue)
- [c]队列queue
- C#queue队列总结
- JAVA QUEUE 队列 使用
- (C#)使用队列(Queue)解决简单的并发问题
- std::queue
- std::queue
- std::queue
- std::queue
- C实现消息队列Queue
- 队列(Queue) C 语言实现
- C语言实现队列Queue
- 关于Android的一些资源
- IQueryable与IEnumberable的区别
- springMVC事务和仓库注解
- mac 下如何开启 ftp server
- java实现简单的单点登录
- C++队列模板使用std::queue
- 初次
- iOS杂谈
- mysql 重设密码以及允许远程访问
- C++线程安全队列
- startActivityForResult 使用注意事项
- 一次内存泄漏导致的OOM实例分析和解决
- springMVC每一层的注解
- 短信接口被攻击后的处理