Skip to content

Conversation

@YeonguChoe
Copy link

Refactor with std::atomic

@YeonguChoe YeonguChoe requested a review from a team as a code owner December 27, 2025 11:24
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Dec 27, 2025
@AlexGuteniev
Copy link
Contributor

Sorry, this cannot work. The counter is visible in the header:

__PURE_APPDOMAIN_GLOBAL static int _Init_cnt; // net ctor count

so changing its type cannot be done in an ABI-compatible way.

Why do you want to make it atomic in the first place?

int& ios_base::Init::_Init_cnt_func() {
return ios_base::Init::_Init_cnt;
}
static std::atomic<int> _Init_cnt{0};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you really want atomicity here, perhaps you can use atomic_ref.

@StephanTLavavej
Copy link
Member

This isn't getting past the early build for any architecture. We welcome pull requests but we really need contributors to validate their own changes, starting with actually building the STL and running some tests locally.

This change is both impossible (can't mess with DLL-exported iostreams machinery) and unnecessary. There is no multithreading contention during initialization/teardown of the standard streams, as indicated by our current lack of locking/atomic ops.

Finally, please provide more detailed descriptions in pull requests - not just what you're doing, but why. In this case, if you believe that multithreading contention is an issue we've totally neglected for 30 years, we'll need a writeup explaining the scenario.

@github-project-automation github-project-automation bot moved this from Initial Review to Done in STL Code Reviews Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants