gpt4 book ai didi

c++ - 是否明确定义了哪个线程调用thread_local存储的构造函数?

转载 作者:行者123 更新时间:2023-12-02 09:52:11 24 4
gpt4 key购买 nike

C++标准是否定义了如何,何时以及通过哪个线程调用thread_local变量的构造函数?例如,是否总是为线程本身分配了thread_local数据?还是产生新线程的线程?还是过程的第一个线程?还是取决于编译器?

最佳答案

[basic.start.dynamic] It is implementation-defined whether the dynamic initialization of a non-local non-inline variable with thread storage duration is sequenced before the first statement of the initial function of a thread or is deferred. If it is deferred, the initialization associated with the entity for thread t is sequenced before the first non-initialization odr-use by t of any non-inline variable with thread storage duration defined in the same translation unit as the variable to be initialized. It is implementation-defined in which threads and at which points in the program such deferred dynamic initialization occurs.

关于c++ - 是否明确定义了哪个线程调用thread_local存储的构造函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63759706/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com