template<typename T>
sprawl::threading::ThreadLocal<T>::ThreadLocal()
{
m_key = TlsAlloc();
}
template<typename T>
sprawl::threading::ThreadLocal<T>::ThreadLocal(T const& value)
{
m_key = TlsAlloc();
set(value);
}
template<typename T>
sprawl::threading::ThreadLocal<T>::~ThreadLocal()
{
TlsFree(m_key);
}
template<typename T>
T* sprawl::threading::ThreadLocal<T>::get()
{
return reinterpret_cast<T*>(TlsGetValue(m_key));
}
template<typename T>
T const* sprawl::threading::ThreadLocal<T>::get() const
{
return reinterpret_cast<T*>(TlsGetValue(m_key));
}
template<typename T>
void sprawl::threading::ThreadLocal<T>::set(T const& value)
{
T* oldValue = reinterpret_cast<T*>(TlsGetValue(m_key));
if(oldValue)
{
*oldValue = value;
}
else
{
TlsSetValue(m_key, (void*)(new T(value)));
}
}
template<typename T>
sprawl::threading::ThreadLocal<T*>::ThreadLocal()
{
m_key = TlsAlloc();
}
template<typename T>
sprawl::threading::ThreadLocal<T*>::ThreadLocal(T const* value)
{
m_key = TlsAlloc();
set(value);
}
template<typename T>
sprawl::threading::ThreadLocal<T*>::~ThreadLocal()
{
TlsFree(m_key);
}
template<typename T>
T* sprawl::threading::ThreadLocal<T*>::get()
{
return reinterpret_cast<T*>(TlsGetValue(m_key));
}
template<typename T>
T const* sprawl::threading::ThreadLocal<T*>::get() const
{
return reinterpret_cast<T*>(TlsGetValue(m_key));
}
template<typename T>
void sprawl::threading::ThreadLocal<T*>::set(T const* value)
{
TlsSetValue(m_key, (void*)(value));
}
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #1 | 13650 | ShadauxCat |
- Windows implementations of thread and time libraries - Added coroutines - Added some more unit tests, fixed some unit tests in windows environments - Fixed an issue where multi threading was not properly detected on Linux - Fixed the makefiles to build with threading by default on linux - Changed the pool allocator to use thread-local pools instead of locking mutexes - Fixed output of sprawl::string in the StringBuilder library to take length into account - Added string builder options for StringLiteral - Added thread local implementation #review |