Open vziparo opened 8 years ago
Assuming that the code you gave above is in a header, it would result the Experiments static class object getting created for every compilation unit. Try setting the static Experiments _instance;
to extern Experiments _instance;
and then defining it in the .cpp.
Thank you for the prompt reply. I will follow your advice. Once I have safely constructed the object and I have just one static class object, will the library be thread safe for concurrent read-only operations? Thanks!
Yes, I think it should be thread-safe for read-only operations, from what I can tell. In my application I personally parse and load the config file into my structures. This for me doesn't cause much overhead, as the config is reloaded very rarely.
Please note that I'm not a maintainer of the library but just a developer with some experience using it.
yaml-cpp is not necessarily threadsafe for all read-only operations, though it is for some. I haven't verified in detail, but I believe, if you have a const YAML::Node
:
But:
YAML::Node
are not threadsafe. I'm not 100% sure, however, since I've never tested this.
Thank you!
Hello, I am using this version of yaml-cpp
commit 57805dfd6a741e55477ea8d4d5b3b6f0272d1f0e Author: Rodrigo Hernandez kwizatz@aeongames.com Date: Tue Jan 26 11:45:00 2016 -0600_
And running in some weird errors. I use the library inside a singleton that is accessed by a number of threads read-only. The code looks like this:
Is yaml-cpp thread-safe?
This is the stack trace I get:
Thanks! Vittorio