1 #ifndef H_CAN_BUFFERED_READER
2 #define H_CAN_BUFFERED_READER
7 #include <boost/thread/mutex.hpp>
8 #include <boost/thread/condition_variable.hpp>
9 #include <boost/chrono.hpp>
16 boost::condition_variable
cond_;
24 ROSCANOPEN_ERROR(
"socketcan_interface",
"buffer overflow, discarded oldest message " );
30 boost::mutex::scoped_lock lock(
mutex_);
52 boost::mutex::scoped_lock lock(
mutex_);
56 boost::mutex::scoped_lock lock(
mutex_);
61 boost::mutex::scoped_lock lock(
mutex_);
65 boost::mutex::scoped_lock lock(
mutex_);
71 boost::mutex::scoped_lock lock(
mutex_);
76 boost::mutex::scoped_lock lock(
mutex_);
81 boost::mutex::scoped_lock lock(
mutex_);
86 boost::mutex::scoped_lock lock(
mutex_);
91 template<
typename DurationType>
bool read(
can::Frame * msg,
const DurationType &duration){
92 return readUntil(msg, boost::chrono::high_resolution_clock::now() + duration);
95 boost::mutex::scoped_lock lock(
mutex_);
97 while(
buffer_.empty() &&
cond_.wait_until(lock,abs_time) != boost::cv_status::timeout)