I'm working on an Event based architecture for a research project. The system currently uses Qt signalling, but we are trying to move away from Qt, so I need something that will work almost as well as the Qt event loop and signals across threads.
Probably against my better judgement, I've chosen to use variadic templates to create a generic event that will be used to perform the callback in the destination thread.
template<typename dest, typename... args>
class Event {
public:
Event(dest* d, void(dest::*func)(args...), args... a)
: d(d), func(func), pass(a...) { }
virtual void perform() {
(d->*func)(pass...);
}
protected:
dest* d;
void(dest::*func)(args...);
args... pass;
};
I haven't found anything that indicates if this is possible. However, I have a hard time believing that it isn't. Given that, I was wondering if there is a way to do something like this and if there isn't, why? Also, if anybody has a better way of doing this I would welcome the suggestion.