Skip to content

Cereal Thread Safe for different archives? #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
volcoma opened this issue Jul 13, 2016 · 4 comments
Closed

Cereal Thread Safe for different archives? #315

volcoma opened this issue Jul 13, 2016 · 4 comments
Milestone

Comments

@volcoma
Copy link

volcoma commented Jul 13, 2016

So is it thread safe to load whole different archives on different threads. Is something preventing cereal to operate multiple archives in parallel? Please somene answer as i did not find apropriate answer for this

@ChrisBFX
Copy link

No, sadly it is not. Cereal uses several StaticObjects which are not thread safe. For example the versioning-feature uses a static std::unorderd_map without a mutex.

@AzothAmmo
Copy link
Contributor

We don't have the mutexes in place but it is easy to make cereal thread safe for cases like you describe by adding mutexes over the global objects. I believe there have been prior discussions on how to do this. Perhaps in a future release we can make a preprocessor option to compile in locks on these operations.

@AzothAmmo
Copy link
Contributor

The current develop branch should be thread safe so long as each archive is only accessed by one thread, though you will need to ensure CEREAL_THREAD_SAFE=1 is defined (see cereal/macros.hpp). Documentation will follow shortly.

@volcoma
Copy link
Author

volcoma commented Aug 1, 2016

well thanks man, that's great 👍

@AzothAmmo AzothAmmo added this to the v1.2.1 milestone Aug 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants