mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 13:43:33 +08:00
new IntrusiveSortedList container used for uORB, WorkQueues, and WorkItems
- new intrusive linked list container (c++ template) that sorts on insertion - primarily for convenience inspecting things in the system like uORB or WorkQueues - uorb status or top sorted alphabetically - work_queue status threads sorted by priority, then items sorted alphabetically within each
This commit is contained in:
@@ -37,15 +37,18 @@
|
||||
#include "WorkQueue.hpp"
|
||||
|
||||
#include <containers/IntrusiveQueue.hpp>
|
||||
#include <containers/IntrusiveSortedList.hpp>
|
||||
#include <px4_platform_common/defines.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <lib/mathlib/mathlib.h>
|
||||
#include <lib/perf/perf_counter.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
namespace px4
|
||||
{
|
||||
|
||||
class WorkItem : public ListNode<WorkItem *>, public IntrusiveQueueNode<WorkItem *>
|
||||
class WorkItem : public IntrusiveSortedListNode<WorkItem *>, public IntrusiveQueueNode<WorkItem *>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -57,6 +60,9 @@ public:
|
||||
WorkItem(WorkItem &&) = delete;
|
||||
WorkItem &operator=(WorkItem &&) = delete;
|
||||
|
||||
// WorkItems sorted by name
|
||||
bool operator<=(const WorkItem &rhs) const { return (strcmp(ItemName(), rhs.ItemName()) <= 0); }
|
||||
|
||||
inline void ScheduleNow()
|
||||
{
|
||||
if (_wq != nullptr) {
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace px4
|
||||
|
||||
class WorkItem;
|
||||
|
||||
class WorkQueue : public ListNode<WorkQueue *>
|
||||
class WorkQueue : public IntrusiveSortedListNode<WorkQueue *>
|
||||
{
|
||||
public:
|
||||
explicit WorkQueue(const wq_config_t &wq_config);
|
||||
@@ -56,7 +56,8 @@ public:
|
||||
|
||||
~WorkQueue();
|
||||
|
||||
const char *get_name() { return _config.name; }
|
||||
const wq_config_t &get_config() const { return _config; }
|
||||
const char *get_name() const { return _config.name; }
|
||||
|
||||
bool Attach(WorkItem *item);
|
||||
void Detach(WorkItem *item);
|
||||
@@ -72,6 +73,9 @@ public:
|
||||
|
||||
void print_status(bool last = false);
|
||||
|
||||
// WorkQueues sorted numerically by relative priority (-1 to -255)
|
||||
bool operator<=(const WorkQueue &rhs) const { return _config.relative_priority >= rhs.get_config().relative_priority; }
|
||||
|
||||
private:
|
||||
|
||||
bool should_exit() const { return _should_exit.load(); }
|
||||
|
||||
Reference in New Issue
Block a user