Convert HotGoal over to event loops.
Change-Id: I43f9e4b26f89e5758cb4a18d91694cdb68186361
diff --git a/y2014/hot_goal_reader.cc b/y2014/hot_goal_reader.cc
index 0b99edb..a772633 100644
--- a/y2014/hot_goal_reader.cc
+++ b/y2014/hot_goal_reader.cc
@@ -6,28 +6,23 @@
#include <arpa/inet.h>
#include <unistd.h>
-#include "aos/time/time.h"
-#include "aos/logging/queue_logging.h"
-#include "aos/logging/logging.h"
-#include "aos/init.h"
#include "aos/byteorder.h"
-
+#include "aos/events/shm-event-loop.h"
+#include "aos/init.h"
+#include "aos/logging/logging.h"
+#include "aos/logging/queue_logging.h"
+#include "aos/time/time.h"
#include "y2014/queues/hot_goal.q.h"
int main() {
::aos::InitNRT();
- uint64_t left_count, right_count;
- ::y2014::hot_goal.FetchLatest();
- if (::y2014::hot_goal.get()) {
- LOG_STRUCT(DEBUG, "starting with", *::y2014::hot_goal);
- left_count = ::y2014::hot_goal->left_count;
- right_count = ::y2014::hot_goal->left_count;
- } else {
- LOG(DEBUG, "no starting message\n");
- left_count = right_count = 0;
- }
+ ::aos::ShmEventLoop shm_event_loop;
+ ::aos::Sender<::y2014::HotGoal> hot_goal_sender =
+ shm_event_loop.MakeSender<::y2014::HotGoal>(".y2014.hot_goal");
+
+ uint64_t left_count = 0, right_count = 0;
int my_socket = -1;
while (true) {
if (my_socket == -1) {
@@ -87,7 +82,7 @@
}
if (data & 0x01) ++right_count;
if (data & 0x02) ++left_count;
- auto message = ::y2014::hot_goal.MakeMessage();
+ auto message = hot_goal_sender.MakeMessage();
message->left_count = left_count;
message->right_count = right_count;
LOG_STRUCT(DEBUG, "sending", *message);