cleaned up queue wrapper stuff
diff --git a/aos/common/queue.h b/aos/common/queue.h
index 6c33822..927f11f 100644
--- a/aos/common/queue.h
+++ b/aos/common/queue.h
@@ -213,15 +213,19 @@
// Fetches the next message from the queue.
// Returns true if there was a new message available and we successfully
- // fetched it. This removes the message from the queue for all readers.
+ // fetched it.
bool FetchNext();
- bool FetchNextBlocking();
+ void FetchNextBlocking();
// Fetches the last message from the queue.
// Returns true if there was a new message available and we successfully
// fetched it.
bool FetchLatest();
+ // Fetches another message from the queue. Blocks until there is one if the
+ // latest was already Fetched.
+ void FetchAnother();
+
// Returns the age of the message.
const time::Time Age() { return time::Time::Now() - queue_msg_->sent_time; }
diff --git a/aos/common/queue_test.cc b/aos/common/queue_test.cc
index 58c88dc..dfafe6a 100644
--- a/aos/common/queue_test.cc
+++ b/aos/common/queue_test.cc
@@ -34,7 +34,7 @@
MyThread() : threaded_test_queue(".aos.common.testing.test_queue") {}
virtual void Run() {
- ASSERT_TRUE(threaded_test_queue.FetchNextBlocking());
+ threaded_test_queue.FetchNextBlocking();
EXPECT_TRUE(threaded_test_queue->test_bool);
EXPECT_EQ(0x971, threaded_test_queue->test_int);
}
diff --git a/aos/linux_code/queue-tmpl.h b/aos/linux_code/queue-tmpl.h
index 15029986..64121f3 100644
--- a/aos/linux_code/queue-tmpl.h
+++ b/aos/linux_code/queue-tmpl.h
@@ -193,12 +193,12 @@
}
template <class T>
-bool Queue<T>::FetchNextBlocking() {
+void Queue<T>::FetchNextBlocking() {
Init();
- const T *msg = static_cast<const T *>(queue_->ReadMessageIndex(RawQueue::kBlock, &index_));
+ const T *msg = static_cast<const T *>(
+ queue_->ReadMessageIndex(RawQueue::kBlock, &index_));
queue_msg_.reset(msg);
assert (msg != NULL);
- return true;
}
template <class T>
@@ -218,6 +218,11 @@
}
template <class T>
+void Queue<T>::FetchAnother() {
+ if (!FetchLatest()) FetchNextBlocking();
+}
+
+template <class T>
SafeScopedMessagePtr<T> Queue<T>::SafeMakeMessage() {
Init();
SafeScopedMessagePtr<T> safe_msg(queue_);