px4_work_queue: minor status changes

- only record start time on first run rather than init
 - increase name length
 - round average interval to nearest microsecond
 - basic formatting consistency (google style guide)
This commit is contained in:
Daniel Agar
2020-05-23 11:51:23 -04:00
parent dd9c82eb20
commit 8ee0a5d328
6 changed files with 49 additions and 67 deletions
@@ -39,7 +39,7 @@
#include <containers/IntrusiveQueue.hpp>
#include <px4_platform_common/defines.h>
#include <drivers/drv_hrt.h>
#include <lib/mathlib/mathlib.h>
#include <lib/perf/perf_counter.h>
namespace px4
@@ -91,7 +91,14 @@ protected:
void ScheduleClear();
protected:
void RunPreamble() { _run_count++; }
void RunPreamble()
{
_run_count++;
if (_time_first_run == 0) {
_time_first_run = hrt_absolute_time();
}
}
friend void WorkQueue::Run();
virtual void Run() = 0;
@@ -111,10 +118,9 @@ protected:
float average_rate() const;
float average_interval() const;
hrt_abstime _start_time{0};
unsigned _run_count{0};
hrt_abstime _time_first_run{0};
const char *_item_name;
uint32_t _run_count{0};
private:
@@ -76,7 +76,7 @@ private:
bool should_exit() const { return _should_exit.load(); }
inline void signal_worker_thread();
inline void SignalWorkerThread();
#ifdef __PX4_NUTTX
// In NuttX work can be enqueued from an ISR