Core/Thread: Add posibility of setting thread name

This commit is contained in:
Lynix
2017-06-20 08:16:08 +02:00
parent 4a1a335cee
commit 50a3f78f91
6 changed files with 128 additions and 13 deletions

View File

@@ -117,6 +117,25 @@ namespace Nz
m_impl = nullptr;
}
/*!
* \brief Changes the debugging name associated to a thread
*
* Changes the debugging name associated with a particular thread, and may helps with debugging tools.
*
* \param name The new name of the thread
*
* \remark Due to system limitations, thread name cannot exceed 15 characters (excluding null-terminator)
*
* \see SetCurrentThreadName
*/
void Thread::SetName(const String& name)
{
NazaraAssert(m_impl, "Invalid thread");
NazaraAssert(name.GetSize() < 16, "Thread name is too long");
m_impl->SetName(name);
}
/*!
* \brief Moves the other thread into this
* \return A reference to this
@@ -145,18 +164,35 @@ namespace Nz
* \brief Gets the number of simulatenous threads that can run on the same cpu
* \return The number of simulatenous threads
*/
unsigned int Thread::HardwareConcurrency()
{
return HardwareInfo::GetProcessorCount();
}
/*!
* \brief Changes the debugging name associated to the calling thread
*
* Changes the debugging name associated with the calling thread, and may helps with debugging tools.
*
* \param name The new name associated with this thread
*
* \remark Due to system limitations, thread name cannot exceed 15 characters (excluding null-terminator)
*
* \see SetName
*/
void Thread::SetCurrentThreadName(const String& name)
{
NazaraAssert(name.GetSize() < 16, "Thread name is too long");
ThreadImpl::SetCurrentName(name);
}
/*!
* \brief Makes sleep this thread
*
* \param milliseconds The number of milliseconds to sleep
*/
void Thread::Sleep(UInt32 milliseconds)
{
ThreadImpl::Sleep(milliseconds);