개정판 0a64fa85
issue #0000 convert service Dapper update
Change-Id: I02cd47be3839ceff08813bd022cb8e13cf534ba0
ConvertService/ServiceBase/Markus.Service.Station/ServiceStation.cs | ||
---|---|---|
7 | 7 |
using Markus.Service.WcfService; |
8 | 8 |
using Salaros.Configuration; |
9 | 9 |
using System; |
10 |
using System.Collections; |
|
10 | 11 |
using System.Collections.Generic; |
11 | 12 |
using System.ComponentModel; |
12 | 13 |
using System.Data; |
... | ... | |
63 | 64 |
/// 프로세스 카운터 자주 람다식을 사용해서 list<int>로 함. |
64 | 65 |
/// </summary> |
65 | 66 |
private List<Int64> ProcessorAffinityList; |
67 |
private Int64 DefaultAffinity; |
|
66 | 68 |
|
67 | 69 |
private string configFileName; |
68 | 70 |
|
... | ... | |
268 | 270 |
int processCount = Environment.ProcessorCount; |
269 | 271 |
int AffinityScope = processCount; |
270 | 272 |
|
271 |
if (processCount > ServiceProperty.PROCESS_COUNT) |
|
272 |
{ |
|
273 |
AffinityScope = processCount / ServiceProperty.PROCESS_COUNT; |
|
274 |
} |
|
273 |
//Process 자동 배분 |
|
274 |
DefaultAffinity = GetAffinityMask(processCount, processCount); |
|
275 | 275 |
|
276 | 276 |
long affinityMask = 0; |
277 | 277 |
|
278 | 278 |
while (ProcessorAffinityList.Count() < ServiceProperty.PROCESS_COUNT) |
279 |
|
|
280 |
for (int i = ServiceProperty.PROCESS_COUNT; i > 0; i--) |
|
279 | 281 |
{ |
280 |
if(affinityMask <= 1) |
|
281 |
{ |
|
282 |
affinityMask = 1 << (processCount - 1); |
|
283 |
} |
|
284 |
else |
|
282 |
affinityMask = GetAffinityMask(processCount, i); |
|
283 |
|
|
284 |
if (Environment.UserInteractive) |
|
285 | 285 |
{ |
286 |
affinityMask = affinityMask >>1;
|
|
286 |
Console.WriteLine($"index{string.Format("{0:D2}", ProcessorAffinityList.Count())} - {longToBinaryString(affinityMask)}");
|
|
287 | 287 |
} |
288 | 288 |
|
289 | 289 |
ProcessorAffinityList.Add(affinityMask); |
290 | 290 |
} |
291 |
} |
|
291 | 292 |
|
292 |
// for (int i = 0; i < AffinityScope; i += AffinityScope)
|
|
293 |
// {
|
|
294 |
// var bits = new int[processCount];
|
|
293 |
private static long GetAffinityMask(int processCount, int index)
|
|
294 |
{ |
|
295 |
BitArray bitArray = new BitArray(processCount);
|
|
295 | 296 |
|
296 |
// for (int j = i; j < i + AffinityScope; j++) |
|
297 |
// { |
|
298 |
// bits[j] = 1; |
|
299 |
// } |
|
297 |
if (processCount - 1 < index) |
|
298 |
{ |
|
299 |
bitArray = new BitArray(processCount, true); |
|
300 |
} |
|
301 |
else |
|
302 |
{ |
|
303 |
bitArray.Set(index, true); |
|
304 |
} |
|
300 | 305 |
|
301 |
// var affinity = System.Convert.ToInt64(string.Join("", bits), 2);
|
|
306 |
var bits = bitArray.Cast<bool>().Select(bit => bit ? 1 : 0);
|
|
302 | 307 |
|
303 |
//#if DEBUG |
|
304 |
// List<int> test = bits.ToList(); |
|
305 |
// test.Reverse(); |
|
306 |
// System.Diagnostics.Debug.WriteLine($"index{string.Format("0#",i)} - {string.Join("", test)}"); |
|
307 |
//#endif |
|
308 |
// ProcessorAffinityList.Add(affinity); |
|
309 |
// } |
|
308 |
return System.Convert.ToInt64(string.Join("", bits), 2); |
|
309 |
} |
|
310 |
private static string longToBinaryString(long value) |
|
311 |
{ |
|
312 |
string binary = Convert.ToString(value, 2); |
|
313 |
return binary.PadLeft(64, '0'); |
|
310 | 314 |
} |
311 | 315 |
|
312 | 316 |
public void StartService() |
내보내기 Unified diff