I have a static library that has a function such as:
bool CreateObject(Object*& Out_Object)
{
thread_local static volatile Object obj = {};
InitializeObject(&obj);
if(obj.IsValid())
{
Out_Object = &obj;
return(true);
}
return(false);
}
I want this function to manage a thread specific object for each thread that calls it by initializing the object and returning it.
What happens to the memory of obj here, is it located in the local thread storage or somewhere else and is this somewhat safe?
Edit: By safe, I mean 'what are the potential problems here that I'm not seeing?'