Hi,
Our app is using Modern C++ a lot to pub and sub.
However, we have a critical real time thread.
And I think that it is unappropriate to call RTI from real time thread because it may call malloc/calloc and it always takes mutexes,
as the result its timing varies from few microseconds to more than a dozen microseconds for a single .write call.
I am trying to make a ring buffer in memory, copy our objects to it from real time thread and then on a low priority thread forward them to RTI.
But I cannot do that with Modern C++ because it allocates its own memory.
Standard C++ allows me to put the objects to my own memory (like ring buffer),
but we are not ready to rewrite our entire app for Standard C++ because it is much more difficult to use.
I only want to use Standard C++ for those objects, which originate from real time thread.
I tried to include both rti_modern/my_data.hpp and rti_std/my_data.h, but got many naming conflicts.
I tried placing them under their own namespaces, but got even more problems.
Even if I succeeded placing headers under namespaces, I also need to compile my_data.cxx, my_dataPlugin.cxx and my_dataSupport.cxx under namespaces,
which does not work at all.
Any idea how to solve this?
Thank you
Hello John,
The two APIs cannot be safely mixed, as they use incompatible symbol declarations. You'd need to use two different applications, or continue using the Modern C++ application but attempt to optimize your QoS to avoid dynamic memory allocation.
For example, you'd need to configure your applications' DataReaders and DataWriters' Resource Limits so that the samples for the topic are allocated upfront, with "max_samples == initial_samples", among others.
Nonetheless, RTI Connext Pro can't guarantee that runtime memory allocation won't happen, regardless of API used. For those use cases, you might be interested in RTI Connext Micro.
Finally and if you have a Support seat, I'd recommend that you go to the Support Portal and see how our Support engineers can help you.
My problem with Modern C++ is not that RTI allocates memory internally (which can be reduced by QOS),
but that it has dynamic data containers inside the structures, such as std::string and ::rti::core::bounded_sequence< double, 100L >
therefore std::is_trivially_copyable fails on these structures, therefore I cannot copy them safely to a lock-free queue to be handled by a low priority thread
or save them to a binary file.
But Standard C++ meets all these requirement (via loan_contiguous).
So, I would like to use some features of Modern C++ but only as long as data structures allow me to manage memory.
I need to find some middle ground. May be include Modern C++ headers in some .cpp sources and Standard C++ in others? or use C binding?