I read that there was a new keyword in C++: it's __thread
from what I've read.
All I know is that it's a keyword to be used like the static
keyword but I know nothing else. Does this keyword just mean that, for instance, if a variable were declared like so:
__thread int foo;
then anything to do with that variable will be executed with a new thread?
Answer
It's thread_local
, not __thread
. It's used to define variables which has storage duration of the thread.
thread_local
is a new storage duration specifier added in C++0x. There are other storage duration : static, automatic and dynamic.
From this link:
thread local storage duration (C++11 feature). The variable is allocated when the thread begins and deallocated when the thread ends. Each thread has its own instance of the variable. Only variables declared thread_local have this storage duration.
I think the introduction of this keyword was made possible by introducing a standardized memory model in C++0x:
No comments:
Post a Comment