In c++11, do static member variables in classes work properly across thread boundaries? What about DLL boundaries?
Here is a rough cut of the class that causes me to ask:
class IndexedEvent
{
public:
//constructor that is used the very first time an
//instance of this class is constructed
IndexedEvent(Event* ev, int res):point(ev),resolution(res){calculateIndex();}
//constructor to be used every time after that
IndexedEvent(Event* ev):point(ev){calculateIndex();}
...some more member functions...
private:
...some more member functions...
static int resolution;
Event* point;
Index calcIndex;
}
If I set resolution in at the beginning very beginning of program execution will other threads be able to create instances of this IndexedEvent that have this value correctly set? Will functions in imported dlls be able to create instances with resolution correctly set?
If that does not work or if it is not feasible due to hoops that need to be jumped through, could it be solved by making a factory class for IndexedEvent and instead of creating new instances of this class via operator new, create them with a call to the factory class?