From e9bbb68829e972df2e458aa5beec0568d4737f02 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 29 Dec 2018 13:27:21 +0100 Subject: compat/spinlock: implement and use it --- tracker-pt/ftnoir_tracker_pt.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'tracker-pt/ftnoir_tracker_pt.cpp') diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index 7589242d..cee9c2a0 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -10,6 +10,7 @@ #include "cv/video-widget.hpp" #include "compat/camera-names.hpp" #include "compat/math-imports.hpp" +#include "compat/spinlock.hpp" #include "pt-api.hpp" @@ -65,8 +66,7 @@ void Tracker_PT::run() if (new_frame) { - while (center_flag.test_and_set()) - (void)0; + spinlock_guard l(center_flag); *preview_frame = *frame; @@ -112,8 +112,6 @@ void Tracker_PT::run() preview_frame = traits->make_preview(w, h); } } - - center_flag.clear(); } } } @@ -189,13 +187,9 @@ void Tracker_PT::data(double *data) bool Tracker_PT::center() { - while (center_flag.test_and_set()) - (void)0; + spinlock_guard l(center_flag); point_tracker.reset_state(); - - center_flag.clear(); - return false; } -- cgit v1.2.3