Demonstrates a usage and an effect of the chsv_thread_local macro.
#include <iostream>
#include <string>
#include <thread>
#include <mutex>
std::mutex cout_mutex;
{
++rage;
std::lock_guard<std::mutex> lock(cout_mutex);
std::cout << "Rage counter for " << thread_name << ": " << rage << '\n';
}
int main()
{
std::thread a(increase_rage, "a"), b(increase_rage, "b");
{
std::lock_guard<std::mutex> lock(cout_mutex);
std::cout << "Rage counter for main: " << rage << '\n';
}
a.join();
b.join();
return 0;
}
#define chsv_thread_local(type, name)
A macro simplifying work with thread-specific storages. It is introduced to implement syntax similar ...
Definition: chsvthrd.h:1565
An interface for the portable implementation of threads as defined in C11 standard supplemented with ...
std::basic_string< char, std::char_traits< char >, ::Chusov::Memory::allocator< char > > string
An instantiation of the standard basic_string class template for handling multi-byte strings allocate...
Definition: chsvstringex.h:126