Ah, I see that's also discussed in Nynaeve's part 6 article.
Something that I think he doesn't mention is that it does not only fail with dynamically loaded libraries, but also with delay loaded libraries that are linked implicitly.
Unfortunately, we have to ship DLLs at RAD. It's really annoying to have to take the function-call hit to get a thread-local value inside the goddamned memory allocator... but we do.
I'm starting to think that *all* variables should be thread local by default in the future. Or maybe that there should just be no more simple global variable syntax, like if you put
int i;
outside of a function, it would be a compile error. You would have to say :
shared_global int i = 0;
or
thread_local int i = 0;
Accidentally using globals on a thread is such a super common threading error.
"02-16-09 - Low Level Threading Junk Part 2.5"
5 Comments -
Note that the __declspec(thread) mechanism is not supported in explicitely loaded DLLs, which makes it rather useless:
http://msdn.microsoft.com/en-us/library/ms682594(VS.85).aspx
February 17, 2009 at 12:52 PM
Ah, I see that's also discussed in Nynaeve's part 6 article.
Something that I think he doesn't mention is that it does not only fail with dynamically loaded libraries, but also with delay loaded libraries that are linked implicitly.
February 17, 2009 at 1:14 PM
DLL shmee-LL
February 17, 2009 at 2:28 PM
Unfortunately, we have to ship DLLs at RAD. It's really annoying to have to take the function-call hit to get a thread-local value inside the goddamned memory allocator... but we do.
February 18, 2009 at 1:16 AM
Ah the hard life of library providers.
I'm starting to think that *all* variables should be thread local by default in the future. Or maybe that there should just be no more simple global variable syntax, like if you put
int i;
outside of a function, it would be a compile error. You would have to say :
shared_global int i = 0;
or
thread_local int i = 0;
Accidentally using globals on a thread is such a super common threading error.
February 18, 2009 at 9:10 AM