more changes to smartthreadpool

This commit is contained in:
UbitUmarov
2021-01-13 16:23:49 +00:00
parent ec56517c7c
commit 1db6a541bd
5 changed files with 55 additions and 91 deletions

View File

@@ -676,10 +676,6 @@ namespace Amib.Threading
// Process until shutdown.
while (!_shutdown)
{
// Update the last time this thread was seen alive.
// It's good for debugging.
CurrentThreadEntry.IAmAlive();
// The following block handles the when the MaxWorkerThreads has been
// incremented by the user at run-time.
// Double lock for quit.
@@ -693,18 +689,17 @@ namespace Amib.Threading
// This method must be called within this lock or else
// more threads will quit and the thread pool will go
// below the lower limit.
InformCompleted();
//InformCompleted();
break;
}
}
}
CurrentThreadEntry.IAmAlive();
// Wait for a work item, shutdown, or timeout
WorkItem workItem = Dequeue();
// Update the last time this thread was seen alive.
// It's good for debugging.
CurrentThreadEntry.IAmAlive();
// On timeout or shut down.
if (workItem == null)
@@ -720,7 +715,7 @@ namespace Amib.Threading
// This method must be called within this lock or else
// more threads will quit and the thread pool will go
// below the lower limit.
InformCompleted();
//InformCompleted();
break;
}
}
@@ -728,6 +723,8 @@ namespace Amib.Threading
continue;
}
CurrentThreadEntry.IAmAlive();
try
{
// Initialize the value to false
@@ -819,6 +816,7 @@ namespace Amib.Threading
{
InformCompleted();
FireOnThreadTermination();
_workItemsQueue.CloseThreadWaiter();
}
}