Shared class members over Dll Boundary
Now here's a good question: is it possible to share the SAME instance of a static class member variable in a template class over dll boundaries? Currently, both the DLL and the EXE has a local copy of it, which is bad, kinda defeats the purpose of being static.
How and why all comse back to the memory manager class:
Code:
static std::map<const void*, PointerInfo*> m_InfoMap;
static CCriticalSection cThisMapSync;
I need, or want, these to be shared also by any DLL that uses it. I don't know a good solution to it, nor do I think I have a good solution, or can think of one.
The workaround so far, is simply not to use the m_InfoMap static member var at all, hence no locking and no local copies used when using an object passed to a exported Dll function.
Neverless to say, this isn't safe. Not the least bit. Locking variables are supposed to be the same everywhere and only one instance in the class.
Also, I can throw two more questions, which I'm not sure of myself:
I don't suppose there's any locking class in the standard library? I already switched out CMap for std::map.
And...
Member functions such as these:
Code:
template<typename NewT> operator CMemoryManager<NewT>& () const
template<typename T2> static CMemoryManager<T> MemoryManagerNew(T2* pNew) throw(...)
How do you actually define them in the code? I can only define them where they're declared (inline functions). Everytime I try to move them, the compiler will only say it can't find the member function declaration.
Here is what I tried:
Code:
template<typename T, typename T2> CMemoryManager<T>::operator CMemoryManager<T2>& () const { }
This does, of course, generate the error: can't find member function.
Any ideas on that one?