diff --git a/src/lib/iter-stack.hpp b/src/lib/iter-stack.hpp index 0bf5baa72..1426fb6fa 100644 --- a/src/lib/iter-stack.hpp +++ b/src/lib/iter-stack.hpp @@ -130,6 +130,13 @@ namespace lib { return *this; } + IterStack& + push (TY&& movedElm) + { + this->stateCore().emplace_back (movedElm); + return *this; + } + IterStack& insert (TY const& elm) { @@ -177,6 +184,13 @@ namespace lib { return *this; } + IterQueue& + feed (TY&& movedElm) + { + this->stateCore().emplace_front (movedElm); + return *this; + } + IterQueue& insert (TY const& elm) { diff --git a/src/proc/control/command-dispatch.hpp b/src/proc/control/command-dispatch.hpp index bb25c14a2..462c19c74 100644 --- a/src/proc/control/command-dispatch.hpp +++ b/src/proc/control/command-dispatch.hpp @@ -57,8 +57,8 @@ namespace control { public: virtual ~CommandDispatch() { } ///< this is an interface - virtual void clear() =0; /////TODO do we actually need that operation? - virtual void enqueue (Command) =0; + virtual void clear() =0; /////TODO do we actually need that operation? + virtual void enqueue (Command&&) =0; }; diff --git a/src/proc/control/command-queue.hpp b/src/proc/control/command-queue.hpp index 25152b94f..ec29bfbe2 100644 --- a/src/proc/control/command-queue.hpp +++ b/src/proc/control/command-queue.hpp @@ -72,7 +72,7 @@ namespace control { CommandQueue& - feed (Command const& cmd) + feed (Command&& cmd) { if (not cmd.canExec()) throw error::Logic(_Fmt("Reject '%s'. Not suitably prepared for invocation: %s") diff --git a/src/proc/control/proc-dispatcher.cpp b/src/proc/control/proc-dispatcher.cpp index 97c423e62..b2aa7283d 100644 --- a/src/proc/control/proc-dispatcher.cpp +++ b/src/proc/control/proc-dispatcher.cpp @@ -204,10 +204,10 @@ namespace control { /* === CommandDispatch interface === */ void - enqueue (Command cmd) override + enqueue (Command&& cmd) override { Lock sync(this); - queue_.feed (cmd); + queue_.feed (move (cmd)); sync.notifyAll(); } diff --git a/tests/core/proc/control/command-instance-manager-test.cpp b/tests/core/proc/control/command-instance-manager-test.cpp index fd8e28bb7..fc4b85b22 100644 --- a/tests/core/proc/control/command-instance-manager-test.cpp +++ b/tests/core/proc/control/command-instance-manager-test.cpp @@ -75,9 +75,9 @@ namespace test { } void - enqueue (Command cmd) override + enqueue (Command&& cmd) override { - queue_.emplace_front(move (cmd)); + queue_.emplace_front (cmd); } public: diff --git a/tests/core/proc/control/command-queue-test.cpp b/tests/core/proc/control/command-queue-test.cpp index ed2057a08..ff1421ef2 100644 --- a/tests/core/proc/control/command-queue-test.cpp +++ b/tests/core/proc/control/command-queue-test.cpp @@ -116,8 +116,8 @@ namespace test { CommandQueue queue; CHECK (isnil(queue)); - queue.feed (com11); - queue.feed (com12); + queue.feed (Command{com11}); + queue.feed (Command{com12}); CHECK (2 == queue.size()); @@ -141,10 +141,10 @@ namespace test { // NOT binding the second command... CommandQueue queue; - queue.feed (com11); + queue.feed (Command{com11}); CHECK (1 == queue.size()); - VERIFY_ERROR (UNBOUND_ARGUMENTS, queue.feed (com12)); + VERIFY_ERROR (UNBOUND_ARGUMENTS, queue.feed (Command{com12})); CHECK (1 == queue.size()); queue.pop().execSync();