Add convenience prebuilt message send function
This makes it easy to have a "state" flatbuffer pre-built which gets
periodically sent out, rather than re-building one from scratch each
time.
Change-Id: I60cac2e654bfb46681ff523165af17ee47e1929f
diff --git a/aos/events/event_loop.h b/aos/events/event_loop.h
index 5edecf1..4ac6e6d 100644
--- a/aos/events/event_loop.h
+++ b/aos/events/event_loop.h
@@ -249,6 +249,9 @@
// Constructs an above builder.
Builder MakeBuilder();
+ // Sends a prebuilt flatbuffer.
+ bool Send(const Flatbuffer<T> &flatbuffer);
+
// Returns the name of the underlying queue.
const Channel *channel() const { return sender_->channel(); }
diff --git a/aos/events/event_loop_tmpl.h b/aos/events/event_loop_tmpl.h
index ef223a9..0d7b419 100644
--- a/aos/events/event_loop_tmpl.h
+++ b/aos/events/event_loop_tmpl.h
@@ -239,6 +239,11 @@
timing::Watcher *watcher_ = nullptr;
};
+template <typename T>
+bool Sender<T>::Send(const Flatbuffer<T> &flatbuffer) {
+ return sender_->Send(flatbuffer.data(), flatbuffer.size());
+}
+
} // namespace aos
#endif // AOS_EVENTS_EVENT_LOOP_TMPL_H