blob: 8d6b18bc3ecd956b1b774b826c94359440c82971 (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
class Thread;
class CLREventStatic;
class RuntimeInstance;
class Array;
typedef DPTR(RuntimeInstance) PTR_RuntimeInstance;
enum class TrapThreadsFlags
{
None = 0,
AbortInProgress = 1,
TrapThreads = 2
};
class ThreadStore
{
SList<Thread> m_ThreadList;
PTR_RuntimeInstance m_pRuntimeInstance;
CLREventStatic m_SuspendCompleteEvent;
ReaderWriterLock m_Lock;
private:
ThreadStore();
void LockThreadStore();
void UnlockThreadStore();
void SuspendAllThreads(CLREventStatic* pCompletionEvent, bool fireDebugEvent);
public:
class Iterator
{
ReaderWriterLock::ReadHolder m_readHolder;
PTR_Thread m_pCurrentPosition;
public:
Iterator();
~Iterator();
PTR_Thread GetNext();
};
~ThreadStore();
static ThreadStore * Create(RuntimeInstance * pRuntimeInstance);
static Thread * RawGetCurrentThread();
static Thread * GetCurrentThread();
static Thread * GetCurrentThreadIfAvailable();
static PTR_Thread GetSuspendingThread();
static void AttachCurrentThread();
static void AttachCurrentThread(bool fAcquireThreadStoreLock);
static void DetachCurrentThread();
#ifndef DACCESS_COMPILE
static void SaveCurrentThreadOffsetForDAC();
void InitiateThreadAbort(Thread* targetThread, Object * threadAbortException, bool doRudeAbort);
void CancelThreadAbort(Thread* targetThread);
#else
static PTR_Thread GetThreadFromTEB(TADDR pvTEB);
#endif
Boolean GetExceptionsForCurrentThread(Array* pOutputArray, Int32* pWrittenCountOut);
void Destroy();
void SuspendAllThreads(CLREventStatic* pCompletionEvent);
void ResumeAllThreads(CLREventStatic* pCompletionEvent);
static bool IsTrapThreadsRequested();
void WaitForSuspendComplete();
};
typedef DPTR(ThreadStore) PTR_ThreadStore;
ThreadStore * GetThreadStore();
#define FOREACH_THREAD(p_thread_name) \
{ \
ThreadStore::Iterator __threads; \
Thread * p_thread_name; \
while ((p_thread_name = __threads.GetNext()) != NULL) \
{ \
#define END_FOREACH_THREAD \
} \
} \
|