aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty/SmartThreadPool/STPStartInfo.cs
blob: fa9ceb4bb53d0b3ef01812c925b1cb610808fd56 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Ami Bar
// amibar@gmail.com

using System.Threading;

namespace Amib.Threading
{
    /// <summary>
    /// Summary description for STPStartInfo.
    /// </summary>
    public class STPStartInfo : WIGStartInfo
    {
        /// <summary>
        /// Idle timeout in milliseconds.
        /// If a thread is idle for _idleTimeout milliseconds then 
        /// it may quit.
        /// </summary>
        private int _idleTimeout;

        /// <summary>
        /// The lower limit of threads in the pool.
        /// </summary>
        private int _minWorkerThreads;

        /// <summary>
        /// The upper limit of threads in the pool.
        /// </summary>
        private int _maxWorkerThreads;

        /// <summary>
        /// The priority of the threads in the pool
        /// </summary>
        private ThreadPriority _threadPriority;

        /// <summary>
        /// The thread pool name. Threads will get names depending on this.
        /// </summary>
        private string _threadPoolName;

        /// <summary>
        /// If this field is not null then the performance counters are enabled
        /// and use the string as the name of the instance.
        /// </summary>
        private string _pcInstanceName;

        private int _stackSize;

        public STPStartInfo() : base()
        {
            _idleTimeout = SmartThreadPool.DefaultIdleTimeout;
            _minWorkerThreads = SmartThreadPool.DefaultMinWorkerThreads;
            _maxWorkerThreads = SmartThreadPool.DefaultMaxWorkerThreads;
            _threadPriority = SmartThreadPool.DefaultThreadPriority;
            _threadPoolName = SmartThreadPool.DefaultThreadPoolName;
            _pcInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName;
            _stackSize = SmartThreadPool.DefaultStackSize;
        }

        public STPStartInfo(STPStartInfo stpStartInfo) : base(stpStartInfo)
        {
            _idleTimeout = stpStartInfo._idleTimeout;
            _minWorkerThreads = stpStartInfo._minWorkerThreads;
            _maxWorkerThreads = stpStartInfo._maxWorkerThreads;
            _threadPriority = stpStartInfo._threadPriority;
            _threadPoolName = stpStartInfo._threadPoolName;
            _pcInstanceName = stpStartInfo._pcInstanceName;
            _stackSize = stpStartInfo._stackSize;
        }

        public int IdleTimeout
        {
            get { return _idleTimeout; }
            set { _idleTimeout = value; }
        }

        public int MinWorkerThreads
        {
            get { return _minWorkerThreads; }
            set { _minWorkerThreads = value; }
        }

        public int MaxWorkerThreads
        {
            get { return _maxWorkerThreads; }
            set { _maxWorkerThreads = value; }
        }

        public ThreadPriority ThreadPriority
        {
            get { return _threadPriority; }
            set { _threadPriority = value; }
        }

        public virtual string ThreadPoolName
        {
            get { return _threadPoolName; }
            set { _threadPoolName = value; }
        }


        public string PerformanceCounterInstanceName
        {
            get { return _pcInstanceName; }
            set { _pcInstanceName = value; }
        }

        public int StackSize
        {
            get { return _stackSize; }
            set { _stackSize = value; }
        }
    }
}