I'm using C++11 and the built-in threading class std::thread
. Using std::atomic
or std::mutex
makes it easy to synchronise data, but I'm wondering if it is really necessary for "non sensitive" tasks - while maintaining a bug-free application. Let's say there's a class like
class FPS
{
private:
int rate;
public:
void change(const int i)
{rate = i;}
int read(void)
{return rate;}
};
storing the frame rate of a camera. In an application, there is one thread for data acquisition (frame grabbing, etc.) that reads the frame rate, and there's another thread handling a GUI that displays the frame rate. The display is "non crucial" in this case, meaning that the display is allowed to be lagging the actual rate in some cases. I can of course simply use an atomic to make it safe, but still I'm wondering if it is actually a must to guarantee a bug-free performance of the program, assuming the application runs on a multi-core CPU.