]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/arducontrol.cpp
Implement flush() for ArduControl
[r2c2.git] / source / libr2c2 / arducontrol.cpp
index 4b89efac1ac57bb013548727fe71ec191c68f6ae..1bb48d47f88eac60a301fc32720abccf33c83809 100644 (file)
@@ -404,7 +404,7 @@ void ArduControl::tick()
                }
        }
 
-       while(!active_accessory && !accessory_queue.empty())
+       while(power && !active_accessory && !accessory_queue.empty())
        {
                Accessory &acc = *accessory_queue.front();
 
@@ -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<T>::pop(T &item)
        return true;
 }
 
+template<typename T>
+bool ArduControl::Queue<T>::empty() const
+{
+       return items.empty();
+}
+
 
 ArduControl::RefreshTask::RefreshTask():
        next(cycle.end()),