From: Mikko Rasa Date: Wed, 2 Apr 2014 20:15:26 +0000 (+0300) Subject: Implement flush() for ArduControl X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f2de56825be33196785c82a1418056f9e7a34461;p=r2c2.git Implement flush() for ArduControl --- diff --git a/source/libr2c2/arducontrol.cpp b/source/libr2c2/arducontrol.cpp index 9edc1e2..1bb48d4 100644 --- a/source/libr2c2/arducontrol.cpp +++ b/source/libr2c2/arducontrol.cpp @@ -456,6 +456,8 @@ void ArduControl::tick() void ArduControl::flush() { + while(!command_queue.empty() || !accessory_queue.empty()) + tick(); } void ArduControl::save_state() const @@ -657,6 +659,12 @@ bool ArduControl::Queue::pop(T &item) return true; } +template +bool ArduControl::Queue::empty() const +{ + return items.empty(); +} + ArduControl::RefreshTask::RefreshTask(): next(cycle.end()), diff --git a/source/libr2c2/arducontrol.h b/source/libr2c2/arducontrol.h index 8560a13..3bb956b 100644 --- a/source/libr2c2/arducontrol.h +++ b/source/libr2c2/arducontrol.h @@ -219,6 +219,7 @@ private: public: void push(const T &); bool pop(T &); + bool empty() const; }; class Task