Add SetRuntimeRealtimePriority
This lets us move the concept of priority into the event loop rather
than trying to manage it elsewhere. Also add tests to confirm I got
them all.
Change-Id: Iba2651778e8d1eb88dedf71d0efdf05dfc999f2d
diff --git a/aos/events/shm-event-loop.h b/aos/events/shm-event-loop.h
index e8ff267..3d231ba 100644
--- a/aos/events/shm-event-loop.h
+++ b/aos/events/shm-event-loop.h
@@ -45,6 +45,13 @@
void Run() override;
void Exit() override;
+ void SetRuntimeRealtimePriority(int priority) override {
+ if (is_running()) {
+ ::aos::Die("Cannot set realtime priority while running.");
+ }
+ thread_state_->priority_ = priority;
+ }
+
private:
friend class internal::WatcherThreadState;
friend class internal::TimerHandlerState;
@@ -62,6 +69,8 @@
void Exit();
+ void MaybeSetCurrentThreadRealtimePriority();
+
private:
friend class internal::WatcherThreadState;
friend class internal::TimerHandlerState;
@@ -74,6 +83,7 @@
// Used to notify watchers that the loop is done.
std::atomic<bool> loop_running_{false};
bool loop_finished_ = false;
+ int priority_ = -1;
};
// Exclude multiple of the same type for path.