c++ - Fast lock for variables that are read a lot and may be changed from another thread occasionaly -
i'm looking lock, allows thread-safe transition between gui , back-end. just double, i'm sure end being used other things. now part i'm unsure of, on modern cpus, can reading , writing @ same time cause race condition? or when 2 threads try write @ same time. i've encapsulated variables cross threads with, in template object, allows me same use requires locking, here basics: //===================================================================================================== // class store variable in thread safe manner. //===================================================================================================== template <class t> class threadsafevariable { public: threadsafevariable(const t & variable): _stored_variable(variable) { } threadsafevariable(): _stored_variable() { } //===================================================================================================== /// returns stored variable