smartthreadpool: replace its locked dictionary

This commit is contained in:
UbitUmarov
2021-09-03 14:36:57 +01:00
parent 30c479db94
commit 94d1cf1205
6 changed files with 59 additions and 131 deletions

View File

@@ -1,6 +1,7 @@
using System;
using Amib.Threading.Internal;
using System;
using System.Threading;
namespace Amib.Threading
{
@@ -29,19 +30,21 @@ namespace Amib.Threading
/// With this variable a thread can know whatever it belongs to a
/// SmartThreadPool.
/// </summary>
private readonly SmartThreadPool _associatedSmartThreadPool;
private SmartThreadPool _associatedSmartThreadPool;
/// <summary>
/// A reference to the current work item a thread from the thread pool
/// is executing.
/// </summary>
public WorkItem CurrentWorkItem { get; set; }
public Thread WorkThread;
public ThreadEntry(SmartThreadPool stp)
public ThreadEntry(SmartThreadPool stp, Thread th)
{
_associatedSmartThreadPool = stp;
_creationTime = DateTime.UtcNow;
_lastAliveTime = DateTime.MinValue;
WorkThread = th;
}
public SmartThreadPool AssociatedSmartThreadPool
@@ -53,6 +56,12 @@ namespace Amib.Threading
{
_lastAliveTime = DateTime.UtcNow;
}
public void Clean()
{
WorkThread = null;
_associatedSmartThreadPool = null;
}
}
#endregion