px4_work_queue: add WorkItemSingleShot

To run a specific method on a work queue and wait for it to return.
This commit is contained in:
Beat Küng
2020-03-06 11:39:56 +01:00
committed by Daniel Agar
parent 87cd20180c
commit 8c41025565
5 changed files with 160 additions and 0 deletions
@@ -50,6 +50,17 @@ WorkItem::WorkItem(const char *name, const wq_config_t &config) :
}
}
WorkItem::WorkItem(const char *name, const WorkItem &work_item) :
_item_name(name)
{
px4::WorkQueue *wq = work_item._wq;
if ((wq != nullptr) && wq->Attach(this)) {
_wq = wq;
_start_time = hrt_absolute_time();
}
}
WorkItem::~WorkItem()
{
Deinit();