Apollo 11.0
自动驾驶开放平台
apollo::lidar::drivers::SyncQueue< T > 模板类 参考

#include <sync_queue.h>

apollo::lidar::drivers::SyncQueue< T > 的协作图:

Public 成员函数

size_t push (const T &value)
 
pop ()
 
bool popWait (T &ret_ele, unsigned int usec=1000000)
 
void clear ()
 

详细描述

template<typename T>
class apollo::lidar::drivers::SyncQueue< T >

在文件 sync_queue.h66 行定义.

成员函数说明

◆ clear()

template<typename T >
void apollo::lidar::drivers::SyncQueue< T >::clear ( )
inline

在文件 sync_queue.h110 行定义.

110 {
111 std::queue<T> empty;
112 std::lock_guard<std::mutex> lg(mtx_);
113 swap(empty, queue_);
114 }

◆ pop()

template<typename T >
T apollo::lidar::drivers::SyncQueue< T >::pop ( )
inline

在文件 sync_queue.h84 行定义.

84 {
85 T value;
86
87 std::lock_guard<std::mutex> lg(mtx_);
88 if (!queue_.empty()) {
89 value = queue_.front();
90 queue_.pop();
91 }
92
93 return value;
94 }

◆ popWait()

template<typename T >
bool apollo::lidar::drivers::SyncQueue< T >::popWait ( T &  ret_ele,
unsigned int  usec = 1000000 
)
inline

在文件 sync_queue.h96 行定义.

96 {
97 {
98 std::lock_guard<std::mutex> lg(mtx_);
99 if (!queue_.empty()) {
100 ret_ele = queue_.front();
101 queue_.pop();
102 return true;
103 }
104 }
105
106 std::this_thread::sleep_for(std::chrono::microseconds(1000));
107 return false;
108 }

◆ push()

template<typename T >
size_t apollo::lidar::drivers::SyncQueue< T >::push ( const T &  value)
inline

在文件 sync_queue.h68 行定义.

68 {
69 bool empty = false;
70 size_t size = 0;
71
72 {
73 std::lock_guard<std::mutex> lg(mtx_);
74 empty = queue_.empty();
75 queue_.push(value);
76 size = queue_.size();
77 }
78
79 if (empty)
80 cv_.notify_one();
81 return size;
82 }

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