Skip to content

Conversation

@supermerill
Copy link
Contributor

@supermerill supermerill commented May 2, 2021

Hello

Someone had a random bug.
I tracked it to the initialisation of the config enum.
Some of them are thread-safe and some don't, so I put all of them to be thread-safe.
Same for the serialize() that wasn't thread-safe (imo).

I hope I didn't add a typo in the last edit.

bubnikv added a commit that referenced this pull request May 4, 2021
fix un-threadsafe code for creating config enum hashtable. #6475
@bubnikv
Copy link
Collaborator

bubnikv commented May 4, 2021

Thanks for pointing that out. It may have been a problem. Fixed with a7368b9.

The static tables are now initialized statically. Comparing to a static variable inside a function, static variable outside of a function does not require the compiler generated synchronization primitive (which is a bit costly because it flushes write caches on Intel CPUs every time the function is visited), however order of initialization of static variables is not defined between compilation units.

Also the get_enum_names() are statically generated as well.

@bubnikv bubnikv closed this May 4, 2021
@supermerill supermerill deleted the prusa-threadsafe-config branch October 17, 2025 09:27
@supermerill supermerill restored the prusa-threadsafe-config branch October 17, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants