Closed RobertoRoos closed 2 years ago
I forked the official OpenSim Docker image (which only has 4.3) into https://hub.docker.com/repository/docker/be1et/opensim-cpp to also create 4.0, 4.1 and 4.2.
I tested this branch on all those versions and only 4.0 fails. I think that's a reasonable score.
I had a quick look to demonstrate this with a Github action, but I couldn't get it to work (I have no experience with these actions yet).
Thank you very much for the great work @RobertoRoos!
I have refactored Concurrency a few months ago. Other than a code clean, the main changes in Concurrency were an automatic management of poison tokens to close the consumers threads, which can now be achieved by calling the member function rtb::Concurrency::Queue;:close()
, like this:
Queue<int> q;
void produce(int n) {
for (int i{ 0 }; i < n; ++i) {
q.push(i);
}
q.close();
}
From the consumer perspective, the data loop can now be simplified to something like the following:
void consume() {
q.subscribe();
while (auto val{q.pop()}) {
cout << val.value() << endl;
}
q.unsubscribe();
}
Which uses some of the properties of std::optional
. The last substantial change I made was simplifying the implementation of the thread pool pattern, which is now much more streamlined to use, see example .
All these changes are in the develop branch of Concurrency and the master still works as it used to be. However, I have just realised that I made the develop branch the default branch when clonig, which is why you might have had some problems with linking.
Please let me know if you would like to use and test the old version of Concurrency library (which just mean switching to the master branch of Concurrency in your testing environment and reverting the .value()
) or use the new version and do a couple of extra checks that thread still close correctly.
Thank you very much for your help!
@cpizzolato , sorry for the late response. Yeah, I'll base this on the real master branch of Concurrency instead. So the current / old version.
We can then re-evaluate this when a real release of Concurrency is ready and update RTOSim accordingly.
Okay, I think I'm done. It's building now with OpenSim 4.3 and the current master branch of Concurrency.
Let me know if and how you would like it rebased.
Thank you very much for your help! I have merged your changes
Modified RTOSIM to work with OpenSim 4.3.
Relates to #18 .
This is still a work in progress!
Major changes:
sdk/
directory)..value()
a bunch of times to cast anstd::optional<>
type back to a regular type. I'm confused why this wasn't necessary before.Note: I have to load cmake with
cmake .. -DOPENSIM_INSTALL_DIR=/opensim_install -DCMAKE_CXX_STANDARD=17
Without the CXX17 flag
std::optional
wasn't available. Should be add this to the mainCMakeLists.txt
?Testing build with the following Dockerfile: