@@ -41,24 +41,27 @@ namespace extension {
4141 : Reactor(std::move(environment)) {
4242
4343 // Estimate the accuracy of our cv wait and precise sleep
44- for (int i = 0 ; i < 3 ; ++i) {
45- // Estimate the accuracy of our cv wait
46- std::mutex test;
47- std::unique_lock<std::mutex> lock (test);
48- const auto cv_s = NUClear::clock::now ();
49- wait.wait_for (lock, std::chrono::milliseconds (1 ));
50- const auto cv_e = NUClear::clock::now ();
51- const auto cv_a = NUClear::clock::duration (cv_e - cv_s - std::chrono::milliseconds (1 ));
52-
53- // Estimate the accuracy of our precise sleep
54- const auto ns_s = NUClear::clock::now ();
55- util::precise_sleep (std::chrono::milliseconds (1 ));
56- const auto ns_e = NUClear::clock::now ();
57- const auto ns_a = NUClear::clock::duration (ns_e - ns_s - std::chrono::milliseconds (1 ));
58-
59- // Use the largest time we have seen
60- cv_accuracy = cv_a > cv_accuracy ? cv_a : cv_accuracy;
61- ns_accuracy = ns_a > ns_accuracy ? ns_a : ns_accuracy;
44+ {
45+ const util::ThreadPriority priority_lock (PriorityLevel::HIGHEST);
46+ for (int i = 0 ; i < 3 ; ++i) {
47+ // Estimate the accuracy of our cv wait
48+ std::mutex test;
49+ std::unique_lock<std::mutex> lock (test);
50+ const auto cv_s = NUClear::clock::now ();
51+ wait.wait_for (lock, std::chrono::milliseconds (1 ));
52+ const auto cv_e = NUClear::clock::now ();
53+ const auto cv_a = NUClear::clock::duration (cv_e - cv_s - std::chrono::milliseconds (1 ));
54+
55+ // Estimate the accuracy of our precise sleep
56+ const auto ns_s = NUClear::clock::now ();
57+ util::precise_sleep (std::chrono::milliseconds (1 ));
58+ const auto ns_e = NUClear::clock::now ();
59+ const auto ns_a = NUClear::clock::duration (ns_e - ns_s - std::chrono::milliseconds (1 ));
60+
61+ // Use the largest time we have seen
62+ cv_accuracy = cv_a > cv_accuracy ? cv_a : cv_accuracy;
63+ ns_accuracy = ns_a > ns_accuracy ? ns_a : ns_accuracy;
64+ }
6265 }
6366
6467 on<Trigger<ChronoTask>>().then (" Add Chrono task" , [this ](const std::shared_ptr<const ChronoTask>& task) {
0 commit comments