clockwerk-opensim-stable – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | using System; |
2 | using System.Threading; |
||
3 | |||
4 | namespace Amib.Threading |
||
5 | { |
||
6 | /// <summary> |
||
7 | /// Summary description for STPStartInfo. |
||
8 | /// </summary> |
||
9 | public class STPStartInfo : WIGStartInfo |
||
10 | { |
||
11 | private int _idleTimeout = SmartThreadPool.DefaultIdleTimeout; |
||
12 | private int _minWorkerThreads = SmartThreadPool.DefaultMinWorkerThreads; |
||
13 | private int _maxWorkerThreads = SmartThreadPool.DefaultMaxWorkerThreads; |
||
14 | #if !(WINDOWS_PHONE) |
||
15 | private ThreadPriority _threadPriority = SmartThreadPool.DefaultThreadPriority; |
||
16 | #endif |
||
17 | private string _performanceCounterInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName; |
||
18 | private bool _areThreadsBackground = SmartThreadPool.DefaultAreThreadsBackground; |
||
19 | private bool _enableLocalPerformanceCounters; |
||
20 | private string _threadPoolName = SmartThreadPool.DefaultThreadPoolName; |
||
21 | private int? _maxStackSize = SmartThreadPool.DefaultMaxStackSize; |
||
22 | |||
23 | public STPStartInfo() |
||
24 | { |
||
25 | _performanceCounterInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName; |
||
26 | #if !(WINDOWS_PHONE) |
||
27 | _threadPriority = SmartThreadPool.DefaultThreadPriority; |
||
28 | #endif |
||
29 | _maxWorkerThreads = SmartThreadPool.DefaultMaxWorkerThreads; |
||
30 | _idleTimeout = SmartThreadPool.DefaultIdleTimeout; |
||
31 | _minWorkerThreads = SmartThreadPool.DefaultMinWorkerThreads; |
||
32 | } |
||
33 | |||
34 | public STPStartInfo(STPStartInfo stpStartInfo) |
||
35 | : base(stpStartInfo) |
||
36 | { |
||
37 | _idleTimeout = stpStartInfo.IdleTimeout; |
||
38 | _minWorkerThreads = stpStartInfo.MinWorkerThreads; |
||
39 | _maxWorkerThreads = stpStartInfo.MaxWorkerThreads; |
||
40 | #if !(WINDOWS_PHONE) |
||
41 | _threadPriority = stpStartInfo.ThreadPriority; |
||
42 | #endif |
||
43 | _performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName; |
||
44 | _enableLocalPerformanceCounters = stpStartInfo._enableLocalPerformanceCounters; |
||
45 | _threadPoolName = stpStartInfo._threadPoolName; |
||
46 | _areThreadsBackground = stpStartInfo.AreThreadsBackground; |
||
47 | #if !(_SILVERLIGHT) && !(WINDOWS_PHONE) |
||
48 | _apartmentState = stpStartInfo._apartmentState; |
||
49 | #endif |
||
50 | } |
||
51 | |||
52 | /// <summary> |
||
53 | /// Get/Set the idle timeout in milliseconds. |
||
54 | /// If a thread is idle (starved) longer than IdleTimeout then it may quit. |
||
55 | /// </summary> |
||
56 | public virtual int IdleTimeout |
||
57 | { |
||
58 | get { return _idleTimeout; } |
||
59 | set |
||
60 | { |
||
61 | ThrowIfReadOnly(); |
||
62 | _idleTimeout = value; |
||
63 | } |
||
64 | } |
||
65 | |||
66 | |||
67 | /// <summary> |
||
68 | /// Get/Set the lower limit of threads in the pool. |
||
69 | /// </summary> |
||
70 | public virtual int MinWorkerThreads |
||
71 | { |
||
72 | get { return _minWorkerThreads; } |
||
73 | set |
||
74 | { |
||
75 | ThrowIfReadOnly(); |
||
76 | _minWorkerThreads = value; |
||
77 | } |
||
78 | } |
||
79 | |||
80 | |||
81 | /// <summary> |
||
82 | /// Get/Set the upper limit of threads in the pool. |
||
83 | /// </summary> |
||
84 | public virtual int MaxWorkerThreads |
||
85 | { |
||
86 | get { return _maxWorkerThreads; } |
||
87 | set |
||
88 | { |
||
89 | ThrowIfReadOnly(); |
||
90 | _maxWorkerThreads = value; |
||
91 | } |
||
92 | } |
||
93 | |||
94 | #if !(WINDOWS_PHONE) |
||
95 | /// <summary> |
||
96 | /// Get/Set the scheduling priority of the threads in the pool. |
||
97 | /// The Os handles the scheduling. |
||
98 | /// </summary> |
||
99 | public virtual ThreadPriority ThreadPriority |
||
100 | { |
||
101 | get { return _threadPriority; } |
||
102 | set |
||
103 | { |
||
104 | ThrowIfReadOnly(); |
||
105 | _threadPriority = value; |
||
106 | } |
||
107 | } |
||
108 | #endif |
||
109 | /// <summary> |
||
110 | /// Get/Set the thread pool name. Threads will get names depending on this. |
||
111 | /// </summary> |
||
112 | public virtual string ThreadPoolName { |
||
113 | get { return _threadPoolName; } |
||
114 | set |
||
115 | { |
||
116 | ThrowIfReadOnly (); |
||
117 | _threadPoolName = value; |
||
118 | } |
||
119 | } |
||
120 | |||
121 | /// <summary> |
||
122 | /// Get/Set the performance counter instance name of this SmartThreadPool |
||
123 | /// The default is null which indicate not to use performance counters at all. |
||
124 | /// </summary> |
||
125 | public virtual string PerformanceCounterInstanceName |
||
126 | { |
||
127 | get { return _performanceCounterInstanceName; } |
||
128 | set |
||
129 | { |
||
130 | ThrowIfReadOnly(); |
||
131 | _performanceCounterInstanceName = value; |
||
132 | } |
||
133 | } |
||
134 | |||
135 | /// <summary> |
||
136 | /// Enable/Disable the local performance counter. |
||
137 | /// This enables the user to get some performance information about the SmartThreadPool |
||
138 | /// without using Windows performance counters. (Useful on WindowsCE, Silverlight, etc.) |
||
139 | /// The default is false. |
||
140 | /// </summary> |
||
141 | public virtual bool EnableLocalPerformanceCounters |
||
142 | { |
||
143 | get { return _enableLocalPerformanceCounters; } |
||
144 | set |
||
145 | { |
||
146 | ThrowIfReadOnly(); |
||
147 | _enableLocalPerformanceCounters = value; |
||
148 | } |
||
149 | } |
||
150 | |||
151 | /// <summary> |
||
152 | /// Get/Set backgroundness of thread in thread pool. |
||
153 | /// </summary> |
||
154 | public virtual bool AreThreadsBackground |
||
155 | { |
||
156 | get { return _areThreadsBackground; } |
||
157 | set |
||
158 | { |
||
159 | ThrowIfReadOnly (); |
||
160 | _areThreadsBackground = value; |
||
161 | } |
||
162 | } |
||
163 | |||
164 | /// <summary> |
||
165 | /// Get a readonly version of this STPStartInfo. |
||
166 | /// </summary> |
||
167 | /// <returns>Returns a readonly reference to this STPStartInfo</returns> |
||
168 | public new STPStartInfo AsReadOnly() |
||
169 | { |
||
170 | return new STPStartInfo(this) { _readOnly = true }; |
||
171 | } |
||
172 | |||
173 | #if !(_SILVERLIGHT) && !(WINDOWS_PHONE) |
||
174 | |||
175 | private ApartmentState _apartmentState = SmartThreadPool.DefaultApartmentState; |
||
176 | |||
177 | /// <summary> |
||
178 | /// Get/Set the apartment state of threads in the thread pool |
||
179 | /// </summary> |
||
180 | public ApartmentState ApartmentState |
||
181 | { |
||
182 | get { return _apartmentState; } |
||
183 | set |
||
184 | { |
||
185 | ThrowIfReadOnly(); |
||
186 | _apartmentState = value; |
||
187 | } |
||
188 | } |
||
189 | |||
190 | #if !(_SILVERLIGHT) && !(WINDOWS_PHONE) |
||
191 | |||
192 | /// <summary> |
||
193 | /// Get/Set the max stack size of threads in the thread pool |
||
194 | /// </summary> |
||
195 | public int? MaxStackSize |
||
196 | { |
||
197 | get { return _maxStackSize; } |
||
198 | set |
||
199 | { |
||
200 | ThrowIfReadOnly(); |
||
201 | if (value.HasValue && value.Value < 0) |
||
202 | { |
||
203 | throw new ArgumentOutOfRangeException("value", "Value must be greater than 0."); |
||
204 | } |
||
205 | _maxStackSize = value; |
||
206 | } |
||
207 | } |
||
208 | #endif |
||
209 | |||
210 | #endif |
||
211 | } |
||
212 | } |