Image

Imageataxi wrote in Imagecpp

Accessing static class members in multithreaded code

Quick question - suppose I have a class as follows:

class A
{
public:
//...
setStaticMember(Foo f) { sm_Foo = f; }
Foo getStaticMember() { return sm_Foo; }

private:
//...
static Foo sm_Foo;
}

Will the accessor methods result in timing issues if I use two instances of A in two threads within a piece of multithreaded code and call the methods whilly-nilly? Or does each thread have its own copy of sm_Foo? If not, what's the quickest resolution?

Just need a quick conceptual leap really *grin*.