mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-25 10:09:36 +02:00
Merge pull request #35 from syvex/POSIXThreadNames
Enable debugging thread names in Thread_POSIX
This commit is contained in:
@@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/Thread_POSIX.h"
|
#include "Poco/Thread_POSIX.h"
|
||||||
|
#include "Poco/Thread.h"
|
||||||
|
#include "Poco/Debugger.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include "Poco/ErrorHandler.h"
|
#include "Poco/ErrorHandler.h"
|
||||||
#include "Poco/Timespan.h"
|
#include "Poco/Timespan.h"
|
||||||
@@ -70,12 +72,34 @@ namespace
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static SignalBlocker signalBlocker;
|
static SignalBlocker signalBlocker;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_DEBUG) && defined(POCO_POSIX_DEBUGGER_THREAD_NAMES)
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
void setThreadName(pthread_t thread, const char* threadName)
|
||||||
|
{
|
||||||
|
if (Poco::Debugger::isAvailable())
|
||||||
|
{
|
||||||
|
# if (POCO_OS == POCO_OS_MAC_OS_X)
|
||||||
|
pthread_setname_np(threadName); // __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
|
||||||
|
# else
|
||||||
|
pthread_setname_np(thread, threadName);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
@@ -372,6 +396,9 @@ void* ThreadImpl::runnableEntry(void* pThread)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ThreadImpl* pThreadImpl = reinterpret_cast<ThreadImpl*>(pThread);
|
ThreadImpl* pThreadImpl = reinterpret_cast<ThreadImpl*>(pThread);
|
||||||
|
#if defined(_DEBUG) && defined(POCO_POSIX_DEBUGGER_THREAD_NAMES)
|
||||||
|
setThreadName(pThreadImpl->_pData->thread, reinterpret_cast<Thread*>(pThread)->getName().c_str());
|
||||||
|
#endif
|
||||||
AutoPtr<ThreadData> pData = pThreadImpl->_pData;
|
AutoPtr<ThreadData> pData = pThreadImpl->_pData;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -410,6 +437,9 @@ void* ThreadImpl::callableEntry(void* pThread)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ThreadImpl* pThreadImpl = reinterpret_cast<ThreadImpl*>(pThread);
|
ThreadImpl* pThreadImpl = reinterpret_cast<ThreadImpl*>(pThread);
|
||||||
|
#if defined(_DEBUG) && defined(POCO_POSIX_DEBUGGER_THREAD_NAMES)
|
||||||
|
setThreadName(pThreadImpl->_pData->thread, reinterpret_cast<Thread*>(pThread)->getName().c_str());
|
||||||
|
#endif
|
||||||
AutoPtr<ThreadData> pData = pThreadImpl->_pData;
|
AutoPtr<ThreadData> pData = pThreadImpl->_pData;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user