diff --git a/src/lib/call-queue.hpp b/src/lib/call-queue.hpp index 5c418041d..cfb138567 100644 --- a/src/lib/call-queue.hpp +++ b/src/lib/call-queue.hpp @@ -40,9 +40,11 @@ #include "lib/error.hpp" #include +#include namespace lib { + namespace error = lumiera::error; @@ -54,6 +56,48 @@ namespace lib { struct CallQueue : boost::noncopyable { + public: + CallQueue() { } + + using Operation = std::function; + + CallQueue& + feed (Operation&& op) + { + if (not op) + throw error::Logic( "Unbound Functor fed to dispatcher CallQueue" + , error::LUMIERA_ERROR_BOTTOM_VALUE); + +// lib::IterQueue::feed (move(cmd)); + return *this; + } + + void + invoke() + { + UNIMPLEMENTED ("pop operation"); + } + + void + clear() + { +// this->stateCore().clear(); + } + + + /* == diagnostics == */ + + size_t + size() const + { +// return unConst(this)->stateCore().size(); + } + + bool + empty() const + { + return 0 == size(); + } }; diff --git a/src/proc/control/command-queue.hpp b/src/proc/control/command-queue.hpp index a74fbe266..cc82b1c69 100644 --- a/src/proc/control/command-queue.hpp +++ b/src/proc/control/command-queue.hpp @@ -67,8 +67,7 @@ namespace control { { public: - CommandQueue() - { } + CommandQueue() { } CommandQueue& @@ -79,7 +78,7 @@ namespace control { % cmd.getID() % cmd , LUMIERA_ERROR_UNBOUND_ARGUMENTS); - lib::IterQueue::feed (move (cmd)); + lib::IterQueue::feed (move(cmd)); return *this; } @@ -103,7 +102,6 @@ namespace control { { return 0 == size(); } - }; diff --git a/tests/library/call-queue-test.cpp b/tests/library/call-queue-test.cpp index fa99bd392..cc0b73cf7 100644 --- a/tests/library/call-queue-test.cpp +++ b/tests/library/call-queue-test.cpp @@ -40,7 +40,7 @@ namespace lib { namespace test{ - using util::cStr; + using util::isnil; using std::bind; using std::string; @@ -77,7 +77,20 @@ namespace test{ void verify_SimpleUse () { - UNIMPLEMENTED("verify_SimpleUse"); + CallQueue queue; + CHECK (isnil (queue)); + + int val = 2; + queue.feed ([&]() { val = -1; }); + CHECK (1 == queue.size()); + CHECK (val == 2); + + queue.invoke(); + CHECK (val == -1); + CHECK (0 == queue.size()); + + queue.invoke(); + CHECK (0 == queue.size()); } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 69d337537..2c1fd309a 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -1047,7 +1047,12 @@ - + + + + + +