2 ms·
Just use thread local variables. I abuse them for ridiculous things.
by imtringued 3y ago
Just use thread local variables.
I abuse them for ridiculous things.
- ComputerGuru 3y agoYeah, I was really into that before there was even a cross-compiler/cross-platform syntax for declaring TLS values in C++ but have since “upgraded” to avoiding TLS altogether where possible. The quality of the implementations vary greatly from compiler and platform to compiler and platform, you run into weird issues with thread_at exit if they’re not primitive types, they run afoul of any fibers/coroutines/etc that have since become extremely prevalent, and a few other things.
- jeltz 3y agoThat is the plan for PostgreSQL.
- menaerus 3y agoThread locals are both blessing and a curse - the problem with them is that you have no lifetime control over such variables.