1#include <Foundation/FoundationInternal.h>
2PL_FOUNDATION_INTERNAL_HEADER
4#include <Foundation/Threading/Implementation/OSThread.h>
5#include <Foundation/Threading/Thread.h>
12 plOSThreadEntryPoint pThreadEntryPoint,
void* pUserData ,
plStringView sName , plUInt32 uiStackSize )
16 m_EntryPoint = pThreadEntryPoint;
17 m_pUserData = pUserData;
19 m_uiStackSize = uiStackSize;
32 pthread_attr_t ThreadAttributes;
33 pthread_attr_init(&ThreadAttributes);
34 pthread_attr_setdetachstate(&ThreadAttributes, PTHREAD_CREATE_JOINABLE);
35 pthread_attr_setstacksize(&ThreadAttributes, m_uiStackSize);
37 int iReturnCode = pthread_create(&m_hHandle, &ThreadAttributes, m_EntryPoint, m_pUserData);
38 PL_IGNORE_UNUSED(iReturnCode);
39 PL_ASSERT_RELEASE(iReturnCode == 0,
"Thread creation failed!");
41#if PL_ENABLED(PL_PLATFORM_LINUX) || PL_ENABLED(PL_PLATFORM_ANDROID)
42 if (iReturnCode == 0 && !m_sName.
IsEmpty())
48 pthread_setname_np(m_hHandle, m_sName.
GetData());
53 strncpy(threadName, m_sName.
GetData(), 15);
54 threadName[15] =
'\0';
55 pthread_setname_np(m_hHandle, threadName);
60 m_ThreadID = m_hHandle;
62 pthread_attr_destroy(&ThreadAttributes);
68 pthread_join(m_hHandle,
nullptr);
T Increment()
Increments the internal value and returns the incremented value.
Definition AtomicInteger_inl.h:35
T Decrement()
Decrements the internal value and returns the decremented value.
Definition AtomicInteger_inl.h:41
virtual ~plOSThread()
Destructor.
Definition OSThread_Posix.h:24
void Join()
Waits in the calling thread until the thread has finished execution (e.g. returned from the thread fu...
Definition OSThread_Posix.h:66
plOSThread(plOSThreadEntryPoint threadEntryPoint, void *pUserData=nullptr, plStringView sName="plOSThread", plUInt32 uiStackSize=128 *1024)
Initializes the thread instance (e.g. thread creation etc.)
Definition OSThread_Posix.h:11
void Start()
Starts the thread.
Definition OSThread_Posix.h:30
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
const char * GetData() const
Returns a pointer to the internal Utf8 string.
Definition String_inl.h:56
plUInt32 GetElementCount() const
Returns the amount of bytes that this string takes (excluding the '\0' terminator).
Definition String_inl.h:65
bool IsEmpty() const
Returns whether the string is an empty string.
Definition StringBase_inl.h:25