Open-Agriculture / AgIsoStack-plus-plus

AgIsoStack++ is the completely free open-source C++ ISOBUS library for everyone
https://agisostack.com/
MIT License
168 stars 40 forks source link

[Core]: Add monitor pattern to allow for concurrent reading #426

Closed GwnDaan closed 4 months ago

GwnDaan commented 5 months ago

Describe your changes

Basically, I had some theory about this in class and thought why not try it out somewhere. ~I think the changes I made won't hurt, and may even solve some potential issues. Namely, the following trace in the CANNetworkManager would currently have let to a deadlock: process_any_control_function_pgn_callbacks() -> some code in callback... -> remove_any_control_function_parameter_group_number_callback() - here the code would try to lock an already locked mutex with no way it will get unlocked after. So even though it may be overkill to allow for multiple readers, it could still be a valuable addition.~

Also, the data_monitor files allows for easy expansion with other monitors to satisfy some other synchronization invariant. While keeping it modular to integrate anywhere as we handle the "disable thread" functionality in the implementation as well.

How has this been tested?

I ran the unit-tests and VT3 example with threads enabled. And a slightly-modified VT3 example with threads disabled.

sonarcloud[bot] commented 5 months ago

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
88.8% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud