少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
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
82
83
84
85
86
#include "il2cpp-config.h"
 
#include "icalls/mscorlib/System.Threading/ThreadPool.h"
#include "os/Environment.h"
#include "vm/Exception.h"
#include "vm/ThreadPool.h"
 
namespace il2cpp
{
namespace icalls
{
namespace mscorlib
{
namespace System
{
namespace Threading
{
    void ThreadPool::GetMaxThreads(int32_t* workerThreads, int32_t* completionPortThreads)
    {
        vm::ThreadPool::Configuration configuration = vm::ThreadPool::GetConfiguration();
 
        if (workerThreads)
            *workerThreads = configuration.maxThreads;
        if (completionPortThreads)
            *completionPortThreads = configuration.maxAsyncIOThreads;
    }
 
    void ThreadPool::GetMinThreads(int32_t* workerThreads, int32_t* completionPortThreads)
    {
        vm::ThreadPool::Configuration configuration = vm::ThreadPool::GetConfiguration();
 
        if (workerThreads)
            *workerThreads = configuration.minThreads;
        if (completionPortThreads)
            *completionPortThreads = configuration.minAsyncIOThreads;
    }
 
    bool ThreadPool::SetMinThreads(int32_t workerThreads, int32_t completionPortThreads)
    {
        vm::ThreadPool::Configuration configuration = vm::ThreadPool::GetConfiguration();
 
        int numCoresAvailable = os::Environment::GetProcessorCount();
        if (workerThreads < numCoresAvailable || workerThreads > configuration.maxThreads)
            return false;
        if (completionPortThreads < numCoresAvailable || completionPortThreads > configuration.maxAsyncIOThreads)
            return false;
 
        configuration.minThreads = workerThreads;
        configuration.minAsyncIOThreads = completionPortThreads;
 
        vm::ThreadPool::SetConfiguration(configuration);
 
        return true;
    }
 
    bool ThreadPool::SetMaxThreads(int32_t workerThreads, int32_t completionPortThreads)
    {
        vm::ThreadPool::Configuration configuration = vm::ThreadPool::GetConfiguration();
 
        if (workerThreads < configuration.minThreads)
            return false;
        if (completionPortThreads < configuration.minAsyncIOThreads)
            return false;
 
        configuration.maxThreads = workerThreads;
        configuration.maxAsyncIOThreads = completionPortThreads;
 
        vm::ThreadPool::SetConfiguration(configuration);
 
        return true;
    }
 
    void ThreadPool::GetAvailableThreads(int32_t* workerThreads, int32_t* completionPortThreads)
    {
        vm::ThreadPool::Configuration configuration = vm::ThreadPool::GetConfiguration();
 
        if (workerThreads)
            *workerThreads = configuration.availableThreads;
        if (completionPortThreads)
            *completionPortThreads = configuration.availableAsyncIOThreads;
    }
} /* namespace Threading */
} /* namespace System */
} /* namespace mscorlib */
} /* namespace icalls */
} /* namespace il2cpp */