BBBsmoke / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

Refactor thread-local storage #783

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The thread-local storage management in libGLESv2/main.cpp needs to be 
refactored. Most of it is platform-independent. DllMain is all that should 
remain in main.cpp; the rest should be moved to shared code and changed to 
fully use the API and constant in src/common/tls.{cpp,h}. Currently it uses a 
Windows-specific constant throughout.

(The question of exactly how the thread-local storage will be maintained on 
both POSIX platforms and Windows going forward still needs to be answered. On 
POSIX platforms it will probably be necessary to lazily allocate both the TLS 
index as well as the per-thread storage, and pass a destructor callback to 
pthread_key_create to clean up each thread's storage.)

Original issue reported on code.google.com by kbr@chromium.org on 11 Oct 2014 at 1:46

GoogleCodeExporter commented 9 years ago
My first attempt at this refactoring moved almost everything from 
libGLESv2/main.cpp into a libGLESv2/ThreadLocals.cpp, leaving just DllMain in 
that file. Interestingly, this caused DllMain to not be included in the 
resulting DLL, and consequently the DLL_PROCESS_ATTACH and DLL_THREAD_ATTACH 
notifications to not be sent to libGLESv2, causing lots of assertion failures.

It looks to me like it's somewhat just lucky that DllMain is being included in 
libGLESv2.dll at this point. I think because it's in a translation unit that 
contains other code, it's being pulled in from libANGLE.lib. (Moving DllMain 
into the new ThreadLocals.cpp caused it to get picked up.)

I'm going to leave everything in main.cpp and #ifdef out DllMain. This does 
need to be rethought as libEGL.dll and libGLESv2.dll begin to share a 
libANGLE.dll.

Original comment by kbr@chromium.org on 11 Oct 2014 at 2:36

GoogleCodeExporter commented 9 years ago

Original comment by shannonw...@chromium.org on 14 Oct 2014 at 5:10

GoogleCodeExporter commented 9 years ago
https://chromium-review.googlesource.com/#/c/222955/ did the above minor 
refactoring.

Original comment by kbr@chromium.org on 15 Oct 2014 at 9:38