少年修仙传客户端基础资源
hch
2024-04-11 4c71d74b77c9eb62a0323698c9a0db3b641a917e
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
#pragma once
 
#if !IL2CPP_THREADS_STD && IL2CPP_THREADS_WIN32
 
#include "os/ErrorCodes.h"
#include "os/Thread.h"
#include "os/WaitStatus.h"
#include "utils/NonCopyable.h"
 
#include "WindowsHeaders.h"
 
#define IL2CPP_DEFAULT_STACK_SIZE ( 1 * 1024 * 1024)            // default .NET stacksize is 1mb
 
namespace il2cpp
{
namespace os
{
    class ThreadImpl : public il2cpp::utils::NonCopyable
    {
    public:
        ThreadImpl();
        ~ThreadImpl();
 
        size_t Id();
        ErrorCode Run(Thread::StartFunc func, void* arg, int64_t affinityMask);
        void SetName(const char* name);
        void SetPriority(ThreadPriority priority);
        ThreadPriority GetPriority();
 
        void SetStackSize(size_t newsize)
        {
            // only makes sense if it's called BEFORE the thread has been created
            IL2CPP_ASSERT(m_ThreadHandle == NULL);
            // if newsize is zero we use the per-platform default value for size of stack
            if (newsize == 0)
            {
                newsize = IL2CPP_DEFAULT_STACK_SIZE;
            }
            m_StackSize = newsize;
        }
 
        static int GetMaxStackSize();
 
        void QueueUserAPC(Thread::APCFunc func, void* context);
 
        ApartmentState GetApartment();
        ApartmentState GetExplicitApartment();
        ApartmentState SetApartment(ApartmentState state);
        void SetExplicitApartment(ApartmentState state);
 
        static void Sleep(uint32_t ms, bool interruptible);
        static size_t CurrentThreadId();
        static ThreadImpl* CreateForCurrentThread();
 
        static bool YieldInternal();
 
#if IL2CPP_HAS_NATIVE_THREAD_CLEANUP
        static void SetNativeThreadCleanup(Thread::ThreadCleanupFunc cleanupFunction);
        static void RegisterCurrentThreadForCleanup(void* arg);
        static void UnregisterCurrentThreadForCleanup();
        static void OnCurrentThreadExiting();
#endif
 
    private:
        HANDLE m_ThreadHandle;
        volatile DWORD m_ThreadId;
        SIZE_T m_StackSize;
        ApartmentState m_ApartmentState;
        ThreadPriority m_Priority;
    };
}
}
 
#endif