17 #ifndef CARTOGRAPHER_COMMON_BLOCKING_QUEUE_H_ 18 #define CARTOGRAPHER_COMMON_BLOCKING_QUEUE_H_ 27 #include "glog/logging.h" 46 explicit BlockingQueue(
const size_t queue_size) : queue_size_(queue_size) {}
52 deque_.push_back(std::move(t));
58 if (!lock.AwaitWithTimeout(
63 deque_.push_back(std::move(t));
72 T t = std::move(deque_.front());
80 if (!lock.AwaitWithTimeout(
85 T t = std::move(deque_.front());
99 return deque_.front().get();
105 return deque_.size();
120 return queue_size_ == kInfiniteQueueSize || deque_.size() < queue_size_;
131 #endif // CARTOGRAPHER_COMMON_BLOCKING_QUEUE_H_
bool PushWithTimeout(T t, const common::Duration timeout)
static constexpr size_t kInfiniteQueueSize
bool QueueEmptyCondition() REQUIRES(mutex_)
BlockingQueue(const size_t queue_size)
const size_t queue_size_ GUARDED_BY(mutex_)
UniversalTimeScaleClock::duration Duration
T PopWithTimeout(const common::Duration timeout)
bool QueueNotFullCondition() REQUIRES(mutex_)
Mutex::Locker MutexLocker
BlockingQueue & operator=(const BlockingQueue &)=delete