Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++11 thread_local keyword support in visual studio 11

So there's a list of c++11 features supported by visual studio.

thread_local support is marked as partial. I was unable to find an explanation of what exactly partial support means here. Did they just alias __declspec(thread)?

I could just use boost::thread_specific_ptr, but there seem to be some reports that boost::thread_specific_ptr is slow. That may or may not be true.

Specifically I want fast TLS on x86/x64 on the most recent linux+gcc and windows+msvc. Fast meaning no system calls where possible (I think this is possible for the platforms above.)

like image 218
Eloff Avatar asked Jan 07 '12 20:01

Eloff


1 Answers

So I did some digging into thread_local semantics. gcc's __thread and msvc's __declspec(thread) have the same semantics as each other and thread_local (dynamic initialization aside, which may or may not have made it into the standard yet.) So this is really a non-issue for my use case. I'll just make a define that aliases one or the other platform specific attribute.

like image 85
Eloff Avatar answered Oct 18 '22 14:10

Eloff