I am writing a generalized clean implementation of C ++ 14 of the signal class with tracking the duration of connected objects and an additional plus that all this works with copy and move operations.
Three types of implementations are now available, which I have now discovered:
Use the global connection_manager , which, well, manages all the connections. This would be terrible in a very parallel scenario where many signals and slots are plugged in and unplugged, and a fine-tuned lock will be required to fix some of these problems.
Each signal retains its connections, and the correct semantics of movement and copying are implemented. This has two drawbacks: the signal object is large, and the operations of moving the road (all connections need to be updated when the signal or connector moves. This burdens both sides with the right movement constructors.
Each signal stores a pointer to a real signal. This additional level of indirection makes movements much cheaper, since the real connected object remains in memory behind the additional level of indirection. The same goes for the connector, although for each signal one additional pointer needs to be dereferenced to get a real object. The semantics of movement are not explicitly required.
I'm currently almost ready for version 2. I donβt know exactly what Qt does, but I know that it covers almost everything I want to do with signals / slots, although the copy / move semantics and the pre-compilation step are.
I missed something or number the third best way to go in the end if I don't want to have a huge impact on signal users (i.e. I don't want to increase the size and complexity of their classes simply because my signal / connectee classes do a lot of work every time they are moved / copied.
Note. I am looking for real experience and suggestions, not opinions.
source share