Convert control loop tests over to simulated event loop
This makes it so that we properly only use ShmEventLoop for running in
realtime on a robot. Very nice.
Change-Id: I46b770b336f59e08cfaf28511b3bd5689f72fff1
diff --git a/aos/input/joystick_input.cc b/aos/input/joystick_input.cc
index a208f1e..0bbba41 100644
--- a/aos/input/joystick_input.cc
+++ b/aos/input/joystick_input.cc
@@ -10,10 +10,6 @@
namespace aos {
namespace input {
-::std::atomic<bool> JoystickInput::run_;
-
-void JoystickInput::Quit(int /*signum*/) { run_ = false; }
-
void JoystickInput::HandleData(const ::aos::JoystickState &joystick_state) {
data_.Update(joystick_state);
@@ -63,27 +59,6 @@
}
RunIteration(data_);
-
- if (!run_) {
- event_loop_->Exit();
- }
-}
-
-void JoystickInput::Run() {
- // TODO(austin): We need a better sigint story for event loops in general.
- run_ = true;
- struct sigaction action;
- action.sa_handler = &JoystickInput::Quit;
- sigemptyset(&action.sa_mask);
- action.sa_flags = SA_RESETHAND;
-
- PCHECK(sigaction(SIGTERM, &action, nullptr));
- PCHECK(sigaction(SIGQUIT, &action, nullptr));
- PCHECK(sigaction(SIGINT, &action, nullptr));
-
- event_loop_->Run();
-
- LOG(INFO, "Shutting down\n");
}
} // namespace input
diff --git a/aos/input/joystick_input.h b/aos/input/joystick_input.h
index 98a89b1..ed72e78 100644
--- a/aos/input/joystick_input.h
+++ b/aos/input/joystick_input.h
@@ -23,10 +23,9 @@
[this](const ::aos::JoystickState &joystick_state) {
this->HandleData(joystick_state);
});
+ event_loop->SetRuntimeRealtimePriority(29);
}
- void Run();
-
protected:
int mode() const { return mode_; }
@@ -36,10 +35,6 @@
// Subclasses should do whatever they want with data here.
virtual void RunIteration(const driver_station::Data &data) = 0;
- static void Quit(int /*signum*/);
-
- static ::std::atomic<bool> run_;
-
EventLoop *event_loop_;
driver_station::Data data_;