Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

jamesr
Copy link
Contributor

@jamesr jamesr commented Feb 10, 2016

C++11 guarantees that initialization of function statics will be
threadsafe. We disabled this by passing -fno-threadsafe-statics because
we used to support building using visual studio and older versions
(older than 2015) did not implement this functionality. Now we only use
modern toolchains which do support this and it's increasingly likely
that libraries we want to use and that other C++ developers will
expect rely on the standard behavior instead of our nonstandard init.
Using the toolchain's implementation of threadsafe initialization is
also very likely to be more efficient than our own handrolled
threadsafe initialization and less error prone.

With the specified behavior, many uses of base::Singleton for threadsafe
initialization can be replaced by function statics for a performance
boost. There's also a very slight risk that code that was depending on
racy initialization could break, but such code is at the very least
suspect if not outright broken already.

Equivalent change in Mojo is here: https://codereview.chromium.org/1683973002

@chinmaygarde
Copy link
Member

Yes! lgtm

@jamesr
Copy link
Contributor Author

jamesr commented Feb 10, 2016

I haven't done any checking of this beyond compile checking. I'll make sure the engine still boots up tomorrow then merge.

jamesr added a commit that referenced this pull request Feb 10, 2016
Enable threadsafe static initialization (aka 'magic statics')
@jamesr jamesr merged commit 306c18c into flutter:master Feb 10, 2016
rhencke pushed a commit to rhencke/engine that referenced this pull request Dec 20, 2020
rhencke pushed a commit to rhencke/engine that referenced this pull request Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants