From de88e3969b211a57a0795f6c93edc8d58e429b84 Mon Sep 17 00:00:00 2001 From: Neeflix Date: Wed, 11 Jul 2018 17:06:28 +0200 Subject: [PATCH 1/3] resolved all merge conflicts --- FlippR-Driver/tests/input/TestEventNotifier.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/FlippR-Driver/tests/input/TestEventNotifier.cpp b/FlippR-Driver/tests/input/TestEventNotifier.cpp index 7066a0d..5ebd61d 100644 --- a/FlippR-Driver/tests/input/TestEventNotifier.cpp +++ b/FlippR-Driver/tests/input/TestEventNotifier.cpp @@ -59,12 +59,8 @@ SCENARIO("An EventHandler gets [un]registered at the notifier", "[un-register no THEN("The EventHandler gets saved") { -<<<<<<< HEAD REQUIRE(*(notifier.event_handlers.find(&event_handler_mock.get())) == &event_handler_mock.get()); REQUIRE_FALSE(notifier.event_handlers.empty() ); -======= - REQUIRE(*notifier.event_handler.begin() == &event_handler_mock.get()); ->>>>>>> ddb6d445dd3d61956203a4864797d0b4d17cd277 } } From 1822b0c6ce6fdae2d06945338f9bf641e2bfdde4 Mon Sep 17 00:00:00 2001 From: Neeflix Date: Wed, 11 Jul 2018 17:17:21 +0200 Subject: [PATCH 2/3] added queue back --- FlippR-Driver/tests/input/TestEventNotifier.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FlippR-Driver/tests/input/TestEventNotifier.cpp b/FlippR-Driver/tests/input/TestEventNotifier.cpp index 5ebd61d..6f64973 100644 --- a/FlippR-Driver/tests/input/TestEventNotifier.cpp +++ b/FlippR-Driver/tests/input/TestEventNotifier.cpp @@ -108,7 +108,7 @@ SCENARIO("The EventHandler gets notified") Event event(0, 0, "test"); Mock event_handler_mock; - When(Method(event_handler_mock, handle)).AlwaysReturn(); + When(Method(event_handler_mock, handle)).AlwaysDo([](Event e){std::cout << "called handle\n";}); Fake(Dtor(event_handler_mock)); Event test_event(0, 0, "test"); @@ -120,6 +120,7 @@ SCENARIO("The EventHandler gets notified") EventNotifier notifier; notifier.event_queue = &(queue_mock.get()); + notifier.event_handlers.insert(&(event_handler_mock.get())); WHEN("The event gets queued") { From 8f12f6ec20afcded2459a6e7553bfa7e9e5933ab Mon Sep 17 00:00:00 2001 From: Neeflix Date: Wed, 11 Jul 2018 17:18:01 +0200 Subject: [PATCH 3/3] jetzt aber :D --- FlippR-Driver/src/utilities/BlockingQueue.hpp | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 FlippR-Driver/src/utilities/BlockingQueue.hpp diff --git a/FlippR-Driver/src/utilities/BlockingQueue.hpp b/FlippR-Driver/src/utilities/BlockingQueue.hpp new file mode 100644 index 0000000..5d431e5 --- /dev/null +++ b/FlippR-Driver/src/utilities/BlockingQueue.hpp @@ -0,0 +1,49 @@ +/* + * BlockingQueue.hpp + * + * Created on: May 17, 2018 + * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht + */ + +#ifndef SRC_UTILITIES_BLOCKINGQUEUE_HPP_ +#define SRC_UTILITIES_BLOCKINGQUEUE_HPP_ + +#include +#include +#include + +#include "IBlockingQueue.h" + +using namespace boost; + +template +class BlockingQueue : public IBlockingQueue +{ +private: + std::mutex d_mutex; + std::condition_variable d_condition; + heap::priority_queue> p_queue; + +public: + void push(T const& value) + { + { + std::unique_lock lock(this->d_mutex); + p_queue.push(value); + } + this->d_condition.notify_one(); + } + + T pop() + { + std::unique_lock lock(this->d_mutex); + this->d_condition.wait(lock, [=]{ return !this->p_queue.empty(); }); + T rc = *this->p_queue.begin(); + this->p_queue.pop(); + return rc; + } +}; + + + +#endif /* SRC_UTILITIES_BLOCKINGQUEUE_HPP_ */