TTicker
This commit is contained in:
@@ -112,7 +112,11 @@ begin
|
||||
|
||||
FWorkGate := TSemaphore.Create(nil, 0, MaxInt, ''); // Initial count is 0, workers will wait
|
||||
|
||||
SetLength(FWorkThreads, TThread.ProcessorCount); // Create one thread per processor core
|
||||
var threadCnt := TThread.ProcessorCount - 1;
|
||||
if threadCnt < 2 then
|
||||
threadCnt := 2;
|
||||
|
||||
SetLength(FWorkThreads, threadCnt);
|
||||
for var i := 0 to High(FWorkThreads) do
|
||||
begin
|
||||
FWorkThreads[i] := CreateAnonymousThread('Thread pool [' + IntToStr(i) + ']', WorkerThread);
|
||||
@@ -158,7 +162,7 @@ begin
|
||||
if TThread.CurrentThread.ThreadID = MainThreadID then
|
||||
begin
|
||||
prio := TThread.CurrentThread.Priority;
|
||||
if prio > Low(TThreadPriority) then
|
||||
if prio > tpLowest then
|
||||
prio := TThreadPriority(Ord(prio) - 1); // Decrease priority by one step
|
||||
|
||||
Result.Priority := prio;
|
||||
|
||||
Reference in New Issue
Block a user