It seems that I was thinking of this back in
d5d8ee8, but left it
unfinished probably because it was simpler to use a Queue directly. Now
some upcoming task management improvements call for it to be a Task.
}
+bool ArduControl::CommandQueueTask::get_work(PendingCommand &cmd)
+{
+ return queue.pop(cmd);
+}
+
+void ArduControl::CommandQueueTask::push(const PendingCommand &cmd)
+{
+ queue.push(cmd);
+}
+
+
ArduControl::RefreshTask::RefreshTask():
next(cycle.end()),
round(0),
control(c),
done(false)
{
+ tasks.push_back(&control.command_queue);
tasks.push_back(&control.monitor);
tasks.push_back(&control.mfx_announce);
tasks.push_back(&control.mfx_search);
bool ArduControl::ControlThread::get_work(PendingCommand &cmd)
{
- if(control.command_queue.pop(cmd))
- return true;
-
for(vector<Task *>::iterator i=tasks.begin(); i!=tasks.end(); ++i)
if((*i)->get_work(cmd))
return true;
public:
virtual bool get_work(PendingCommand &);
+
+ void push(const PendingCommand &);
+ bool empty() const { return queue.empty(); }
};
class RefreshTask: public Task
SensorMap sensors;
Msp::Time::TimeDelta command_timeout;
- Queue<PendingCommand> command_queue;
+ CommandQueueTask command_queue;
Queue<Tag> completed_commands;
RefreshTask refresh;
S88Task s88;