mapbox-gl-native
mapbox-gl-native copied to clipboard
Why not `thread_local`?
The ThreadLocal<T> class depends on each platform's implementation of ThreadLocalBase.
As far as I can tell, mapbox-gl-native already requires C++11 everywhere, and in C++11, TLS is already supported by thread_local keyword.
For instance, one can replace,
mbgl::util::ThreadLocal<mbgl::gfx::BackendScope>& currentScope() {
static mbgl::util::ThreadLocal<mbgl::gfx::BackendScope> backendScope;
return backendScope;
}
... = currentScope().get();
currentScope().set(...);
with
mbgl::gfx::BackendScope*& currentScope() {
thread_local mbgl::gfx::BackendScope* backendScope = nullptr;
return backendScope;
}
... = currentScope();
currentScope() = ...;
Is there any reason to keep the platform dependent implementation? Or, is it just a legacy?
May I make a PR to drop ThreadLocal<T> usage?