1 #ifndef CARMA_UTIL_CONCURRENTQUEUE_H
2 #define CARMA_UTIL_CONCURRENTQUEUE_H
6 #include <carma/util/PthreadCond.h>
7 #include <carma/util/PthreadMutex.h>
8 #include <carma/util/ScopedPthreadMutexLock.h>
18 mutable PthreadMutex mutex_;
22 typedef typename std::queue<T>::size_type size_type;
24 void push(T
const& val);
27 void wait_and_pop(T& val);
28 size_type size()
const;
35 void carma::util::ConcurrentQueue<T>::push(T
const& val)
37 const ScopedPthreadMutexLock lock(mutex_);
44 bool carma::util::ConcurrentQueue<T>::empty()
const
46 const ScopedPthreadMutexLock lock(mutex_);
47 return queue_.empty();
51 bool carma::util::ConcurrentQueue<T>::try_pop(T &val)
53 const ScopedPthreadMutexLock lock(mutex_);
64 void carma::util::ConcurrentQueue<T>::wait_and_pop(T& val)
66 const ScopedPthreadMutexLock lock(mutex_);
68 while (queue_.empty())
76 typename carma::util::ConcurrentQueue<T>::size_type
77 carma::util::ConcurrentQueue<T>::size()
const
79 const ScopedPthreadMutexLock lock(mutex_);