For almost 20y. of Embedded/C++ dev., I often fall back into the same situation of an infinite loop populated with different threaded services Class (start/stopped through Abstract Factory/Singleton design patterns) like TCP Socket, CAN bus, Serial link, logging, power, FDIR, data-pool, Telemetry/Telecomand Engine (Command parser design pattern), all these services being interfaced through RX/TX queues. This leads often to Service-Interface class being instantiated (once, singleton of-course) globaly (don't scream!) and/or having the infinite loop relying on a C/Glib g_main_loop() (don't yell!)
While I often read this kind of architecture being referred as producer/worker/client, I kind of have a hard time finding an appropriate design pattern to follow as a best practice or code reference/skeleton for such an architecture.
I am probably missing the appropriate vocabulary (I am 90% C++ autodidact) and/or the good starting point...
As StackOverflow bans fuzzy questions, I guess my issue could be reduced at understanding what should be (or not!) in the main() function (e.g. where/when to construct/start/stop interface classes) and/or what is a good reference code to read/refer for a multi-threaded/queued-services around an infinite while() loop in modern C++ ?
So indeed rather a philosophical question here, I hope I could describe it in a clear manner...if not, please help me to rephrase it appropriately.
Thank you,
Cheers, Ben
Aucun commentaire:
Enregistrer un commentaire