apollo icon indicating copy to clipboard operation
apollo copied to clipboard

why cyber rt use signal and slot system in the discover and transport section?

Open fengmao31 opened this issue 2 years ago • 3 comments

Cyber RT use signal and slot system in the discover and transport section. When the discovery service changed or the new message coming in the transport layer, it will give the signal. The signal call the callback fuction in slot. Why cyber rt use this mechanism? If it use simple callback directly, I think it can also work.

fengmao31 avatar Aug 22 '23 06:08 fengmao31

The signal and slot mechanism used in Cyber RT's discover and transport sections is a design pattern often employed in software development, particularly in event-driven programming and GUI frameworks. It provides a flexible and decoupled way of handling events and notifications. While using simple callbacks could also work, the signal and slot mechanism offers several advantages that might justify its use: Decoupling Components: Signals and slots allow for a looser coupling between different components of the software. In Cyber RT's case, the discovery service and the transport layer might be developed and maintained by different teams or individuals. Using signals and slots, these components don't need to have direct references to each other, making the system more modular and maintainable. Extensibility: Signals and slots make it easier to add new functionalities without modifying existing code. If you were to use simple callbacks directly, you might need to modify existing callback registration code when introducing new events or changes. With the signal and slot pattern, you can add new slots (callback functions) to a signal (event) without touching the existing code. Multiple Subscribers: Signals can have multiple slots connected to them. This means that multiple components or modules can react to the same event independently. In a callback system, you might need to manage a list of callback functions manually, while signals handle this automatically. Encapsulation and Abstraction: The signal and slot mechanism encapsulates the details of event notification and handling. This abstraction can improve code readability and maintainability, as each component only needs to understand the signals they connect to and the slots they implement. Dynamic Connection: Signals and slots allow dynamic connections and disconnections. This can be helpful when components need to react to events at runtime. Callbacks, on the other hand, are often statically defined during initialization. Potential Thread Safety: Some signal and slot implementations provide built-in thread safety mechanisms. This can be important in concurrent or multithreaded environments, where direct callbacks might require additional synchronization. Cross-Module Communication: In large software systems, different modules or libraries might need to communicate with each other without knowing the internal details. Signals and slots provide a higher-level communication mechanism that can work well in such scenarios.

WTSRUVF avatar Aug 25 '23 09:08 WTSRUVF

Thank you.This answer is a good job.

fengmao31 avatar Aug 28 '23 02:08 fengmao31

Can this signal and slot system in cyber rt communicate with other process as qt's signal and slot system?

fengmao31 avatar Jan 19 '24 10:01 fengmao31