-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
threadstore.inl
44 lines (36 loc) · 1.23 KB
/
threadstore.inl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#ifdef _MSC_VER
// a workaround to prevent tls_CurrentThread from becoming dynamically checked/initialized.
EXTERN_C __declspec(selectany) __declspec(thread) ThreadBuffer tls_CurrentThread;
#else
EXTERN_C __thread ThreadBuffer tls_CurrentThread;
#endif
// static
inline Thread * ThreadStore::RawGetCurrentThread()
{
return (Thread *) &tls_CurrentThread;
}
// static
inline Thread * ThreadStore::GetCurrentThread()
{
Thread * pCurThread = RawGetCurrentThread();
// If this assert fires, and you only need the Thread pointer if the thread has ever previously
// entered the runtime, then you should be using GetCurrentThreadIfAvailable instead.
ASSERT(pCurThread->IsInitialized());
return pCurThread;
}
// static
inline Thread * ThreadStore::GetCurrentThreadIfAvailable()
{
Thread * pCurThread = RawGetCurrentThread();
if (pCurThread->IsInitialized())
return pCurThread;
return NULL;
}
EXTERN_C volatile uint32_t RhpTrapThreads;
// static
inline bool ThreadStore::IsTrapThreadsRequested()
{
return (RhpTrapThreads & (uint32_t)TrapThreadsFlags::TrapThreads) != 0;
}