mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Lazy<T>
, LazyTLS<T>
, thread dtors
This commit is contained in:
parent
cf269db0eb
commit
a27ef9beda
17 changed files with 437 additions and 30 deletions
|
@ -19,6 +19,12 @@ BF_TLS_DECLSPEC Thread* Thread::sCurrentThread;
|
|||
static volatile int gLiveThreadCount;
|
||||
static Beefy::SyncEvent gThreadsDoneEvent;
|
||||
|
||||
#ifdef BF_PLATFORM_WINDOWS
|
||||
extern DWORD gBfTLSKey;
|
||||
#else
|
||||
extern pthread_key_t gBfTLSKey;
|
||||
#endif
|
||||
|
||||
bf::System::Threading::Thread* BfGetCurrentThread()
|
||||
{
|
||||
#ifdef BF_THREAD_TLS
|
||||
|
@ -133,7 +139,8 @@ static void BF_CALLTYPE CStartProc(void* threadParam)
|
|||
bool wantsDelete = false;
|
||||
//
|
||||
{
|
||||
internalThread->ThreadStopped();
|
||||
internalThread->ThreadStopped();
|
||||
|
||||
Beefy::AutoCrit autoCrit(internalThread->mCritSect);
|
||||
if (isAutoDelete)
|
||||
gBfRtCallbacks.Thread_AutoDelete(thread);
|
||||
|
@ -207,15 +214,28 @@ void Thread::StartInternal()
|
|||
#endif
|
||||
}
|
||||
|
||||
void Thread::RequestExitNotify()
|
||||
{
|
||||
// Do we already have implicit exiting notification?
|
||||
if (BfGetCurrentThread() != NULL)
|
||||
return;
|
||||
|
||||
#ifdef BF_PLATFORM_WINDOWS
|
||||
FlsSetValue(gBfTLSKey, (void*)&gBfRtCallbacks);
|
||||
#else
|
||||
pthread_setspecific(gBfTLSKey, (void*)&gBfRtCallbacks);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Thread::ThreadStarted()
|
||||
{
|
||||
auto internalThread = GetInternalThread();
|
||||
internalThread->mCritSect.Unlock();
|
||||
}
|
||||
|
||||
int Thread::GetThreadId()
|
||||
intptr Thread::GetThreadId()
|
||||
{
|
||||
return (int)GetInternalThread()->mThreadId;
|
||||
return GetInternalThread()->mThreadId;
|
||||
}
|
||||
|
||||
void Thread::SetStackStart(void* ptr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue