thread_local Variables in C++. Why useful? How do they work?
thread_local is a new keyword available since C++11, however, the concept of thread local storage is much older, so even before C++11, you could use it through some extensions are system API. The core idea is that each thread contains some special memory block where you can create those variables. Each thread contains a separate copy of those variables. 0:00 Intro 0:20 What is a thread_local variable 1:44 The first example 4:40 The second example 7:00 Why useful & outro See examples at: https://godbolt.org/z/v4e36r5Mf https://godbolt.org/z/7aEToMbT1 and the slides: https://shared.xara.com/xJ3Fe0JqeS join us at cppstories.com
thread_local is a new keyword available since C++11, however, the concept of thread local storage is much older, so even before C++11, you could use it through some extensions are system API. The core idea is that each thread contains some special memory block where you can create those variables. Each thread contains a separate copy of those variables. 0:00 Intro 0:20 What is a thread_local variable 1:44 The first example 4:40 The second example 7:00 Why useful & outro See examples at: https://godbolt.org/z/v4e36r5Mf https://godbolt.org/z/7aEToMbT1 and the slides: https://shared.xara.com/xJ3Fe0JqeS join us at cppstories.com