Move gallant signal wrapper to VSRTL
DELETE
src/gallantsignalwrapper.h
-#pragma once
-
-#include <QMetaObject>
-#include <functional>
-#include "Signals/Signal.h"
-
-namespace Ripes {
-/**
- * class CrossThreadSignalWrapper
- * This class acts as a wrapper for Gallant signals. @p fun will be executed within the event loop context of @p obj,
- * upon signal @p sig being triggered. This serves the following purposes:
- * - Gallant signals only accepts raw pointers as callback functions; we'd like to be able to pass a lambda function.
- * - Gallant signals are not thread safe. The wrapper will ensure that signals go through the signal/slot system of Qt,
- * which checks for, and handles, cross-thread signals.
- */
-struct GallantSignalWrapperBase {
- virtual ~GallantSignalWrapperBase(){};
-};
-
-template <typename F, typename D, typename T>
-class GallantSignalWrapper : public GallantSignalWrapperBase {
-public:
- GallantSignalWrapper(T* obj, F&& fun, D& sig, Qt::ConnectionType type = Qt::AutoConnection) {
- wrapper = [=] { QMetaObject::invokeMethod(obj, fun, type); };
- sig.Connect(this, &GallantSignalWrapper::ftunnel);
- }
-
-private:
- void ftunnel() { wrapper(); }
- std::function<void()> wrapper;
-};
-} // namespace Ripes

MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -271,7 +271,7 @@ void ProcessorHandler::_selectProcessor(const ProcessorID& id, const QStringList
// Connect wrappers for making processor signal emissions thread safe.
m_signalWrappers.clear();
- m_signalWrappers.push_back(std::unique_ptr<GallantSignalWrapperBase>(new GallantSignalWrapper(
+ m_signalWrappers.push_back(std::unique_ptr<vsrtl::GallantSignalWrapperBase>(new vsrtl::GallantSignalWrapper(
this,
[=] {
if (!_isRunning()) {
@@ -285,7 +285,7 @@ void ProcessorHandler::_selectProcessor(const ProcessorID& id, const QStringList
// cross-thread and out of order.
m_currentProcessor->processorWasClocked.Connect(this, &ProcessorHandler::processorClocked);
- m_signalWrappers.push_back(std::unique_ptr<GallantSignalWrapperBase>(new GallantSignalWrapper(
+ m_signalWrappers.push_back(std::unique_ptr<vsrtl::GallantSignalWrapperBase>(new vsrtl::GallantSignalWrapper(
this,
[=] {
emit processorReset();
@@ -293,7 +293,7 @@ void ProcessorHandler::_selectProcessor(const ProcessorID& id, const QStringList
},
m_currentProcessor->processorWasReset)));
- m_signalWrappers.push_back(std::unique_ptr<GallantSignalWrapperBase>(new GallantSignalWrapper(
+ m_signalWrappers.push_back(std::unique_ptr<vsrtl::GallantSignalWrapperBase>(new vsrtl::GallantSignalWrapper(
this,
[=] {
emit processorReversed();

MODIFY
src/processorhandler.h
src/processorhandler.h
@@ -260,6 +260,6 @@ private:
* Semaphore handling locking simulator thread execution whilst trapping to the execution environment.
*/
QSemaphore m_sem;
- std::vector<std::unique_ptr<GallantSignalWrapperBase>> m_signalWrappers;
+ std::vector<std::unique_ptr<vsrtl::GallantSignalWrapperBase>> m_signalWrappers;
};
} // namespace Ripes

Move gallant signal wrapper to VSRTL