integrated fixed from 1.3.4

This commit is contained in:
Guenter Obiltschnig
2009-02-18 13:12:25 +00:00
parent 32642ba9c1
commit 64a7203a0d
8 changed files with 72 additions and 40 deletions

View File

@@ -1,7 +1,7 @@
//
// Thread_WIN32.h
//
// $Id: //poco/svn/Foundation/src/Thread_WIN32.cpp#2 $
// $Id: //poco/Main/Foundation/src/Thread_WIN32.cpp#17 $
//
// Library: Foundation
// Package: Threading
@@ -43,7 +43,7 @@
namespace Poco {
DWORD ThreadImpl::_currentKey = TLS_OUT_OF_INDEXES;
ThreadImpl::CurrentThreadHolder ThreadImpl::_currentThreadHolder;
ThreadImpl::ThreadImpl():
@@ -52,12 +52,6 @@ ThreadImpl::ThreadImpl():
_prio(PRIO_NORMAL_IMPL),
_stackSize(POCO_THREAD_STACK_SIZE)
{
if (_currentKey == TLS_OUT_OF_INDEXES)
{
_currentKey = TlsAlloc();
if (_currentKey == TLS_OUT_OF_INDEXES)
throw SystemException("cannot allocate thread context key");
}
}
@@ -178,10 +172,7 @@ void ThreadImpl::threadCleanup()
ThreadImpl* ThreadImpl::currentImpl()
{
if (_currentKey == TLS_OUT_OF_INDEXES)
return 0;
else
return (ThreadImpl*) TlsGetValue(_currentKey);
return _currentThreadHolder.get();
}
@@ -191,7 +182,7 @@ DWORD WINAPI ThreadImpl::runnableEntry(LPVOID pThread)
unsigned __stdcall ThreadImpl::runnableEntry(void* pThread)
#endif
{
TlsSetValue(_currentKey, pThread);
_currentThreadHolder.set(reinterpret_cast<ThreadImpl*>(pThread));
try
{
reinterpret_cast<ThreadImpl*>(pThread)->_pRunnableTarget->run();
@@ -218,7 +209,7 @@ DWORD WINAPI ThreadImpl::callableEntry(LPVOID pThread)
unsigned __stdcall ThreadImpl::callableEntry(void* pThread)
#endif
{
TlsSetValue(_currentKey, pThread);
_currentThreadHolder.set(reinterpret_cast<ThreadImpl*>(pThread));
try
{
ThreadImpl* pTI = reinterpret_cast<ThreadImpl*>(pThread);