resolved merge conflict
This commit is contained in:
@@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 <mutex>
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <future>
|
|
||||||
#include <boost/heap/priority_queue.hpp>
|
|
||||||
|
|
||||||
#include "IBlockingQueue.h"
|
|
||||||
|
|
||||||
using namespace boost;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class BlockingQueue : public IBlockingQueue<T>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::mutex mutex;
|
|
||||||
std::condition_variable wait_condition;
|
|
||||||
|
|
||||||
heap::priority_queue<T, heap::stable<true>> p_queue;
|
|
||||||
|
|
||||||
public:
|
|
||||||
void push(T const& value)
|
|
||||||
{
|
|
||||||
<<<<<<< HEAD
|
|
||||||
std::lock_guard lock(this->mutex);
|
|
||||||
=======
|
|
||||||
<<<<<<< HEAD
|
|
||||||
{
|
|
||||||
std::unique_lock<std::mutex> lock(this->d_mutex);
|
|
||||||
p_queue.push(value);
|
|
||||||
}
|
|
||||||
this->d_condition.notify_one();
|
|
||||||
=======
|
|
||||||
this->promise.set_value(value);
|
|
||||||
return;
|
|
||||||
>>>>>>> 3e086976076bbe7c104001de6366eff270d039fb
|
|
||||||
}
|
|
||||||
p_queue.push(value);
|
|
||||||
}
|
|
||||||
>>>>>>> a8eddc165087dba2da234c0f3cbe38dd185c26d7
|
|
||||||
|
|
||||||
p_queue.push(value);
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
wait_condition.notify_one();
|
|
||||||
=======
|
|
||||||
auto status = future_pop.wait_for(std::chrono::seconds(0));
|
|
||||||
if(status == std::future_status::ready)
|
|
||||||
{
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// TODO die queue funzt net weil wir nich pushen koennen wenn wir im pop warten
|
|
||||||
// TODO denk ma ueber future nach
|
|
||||||
std::unique_lock<std::mutex> 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;
|
|
||||||
=======
|
|
||||||
return future_pop.get();
|
|
||||||
>>>>>>> 3e086976076bbe7c104001de6366eff270d039fb
|
|
||||||
>>>>>>> a8eddc165087dba2da234c0f3cbe38dd185c26d7
|
|
||||||
}
|
|
||||||
|
|
||||||
T pop()
|
|
||||||
{
|
|
||||||
std::unique_lock lock(this->mutex);
|
|
||||||
while(this->p_queue.empty())
|
|
||||||
{
|
|
||||||
wait_condition.wait(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto element = p_queue.top();
|
|
||||||
p_queue.pop();
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* SRC_UTILITIES_BLOCKINGQUEUE_HPP_ */
|
|
||||||
@@ -59,8 +59,12 @@ SCENARIO("An EventHandler gets [un]registered at the notifier", "[un-register no
|
|||||||
|
|
||||||
THEN("The EventHandler gets saved")
|
THEN("The EventHandler gets saved")
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
REQUIRE(*(notifier.event_handlers.find(&event_handler_mock.get())) == &event_handler_mock.get());
|
REQUIRE(*(notifier.event_handlers.find(&event_handler_mock.get())) == &event_handler_mock.get());
|
||||||
REQUIRE_FALSE(notifier.event_handlers.empty() );
|
REQUIRE_FALSE(notifier.event_handlers.empty() );
|
||||||
|
=======
|
||||||
|
REQUIRE(*notifier.event_handler.begin() == &event_handler_mock.get());
|
||||||
|
>>>>>>> ddb6d445dd3d61956203a4864797d0b4d17cd277
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user