diff options
Diffstat (limited to '')
-rw-r--r-- | ThirdParty/SmartThreadPool/SmartThreadPool.ThreadEntry.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/ThirdParty/SmartThreadPool/SmartThreadPool.ThreadEntry.cs b/ThirdParty/SmartThreadPool/SmartThreadPool.ThreadEntry.cs new file mode 100644 index 0000000..ba7d73f --- /dev/null +++ b/ThirdParty/SmartThreadPool/SmartThreadPool.ThreadEntry.cs | |||
@@ -0,0 +1,60 @@ | |||
1 | | ||
2 | using System; | ||
3 | using Amib.Threading.Internal; | ||
4 | |||
5 | namespace Amib.Threading | ||
6 | { | ||
7 | public partial class SmartThreadPool | ||
8 | { | ||
9 | #region ThreadEntry class | ||
10 | |||
11 | internal class ThreadEntry | ||
12 | { | ||
13 | /// <summary> | ||
14 | /// The thread creation time | ||
15 | /// The value is stored as UTC value. | ||
16 | /// </summary> | ||
17 | private readonly DateTime _creationTime; | ||
18 | |||
19 | /// <summary> | ||
20 | /// The last time this thread has been running | ||
21 | /// It is updated by IAmAlive() method | ||
22 | /// The value is stored as UTC value. | ||
23 | /// </summary> | ||
24 | private DateTime _lastAliveTime; | ||
25 | |||
26 | /// <summary> | ||
27 | /// A reference from each thread in the thread pool to its SmartThreadPool | ||
28 | /// object container. | ||
29 | /// With this variable a thread can know whatever it belongs to a | ||
30 | /// SmartThreadPool. | ||
31 | /// </summary> | ||
32 | private readonly SmartThreadPool _associatedSmartThreadPool; | ||
33 | |||
34 | /// <summary> | ||
35 | /// A reference to the current work item a thread from the thread pool | ||
36 | /// is executing. | ||
37 | /// </summary> | ||
38 | public WorkItem CurrentWorkItem { get; set; } | ||
39 | |||
40 | public ThreadEntry(SmartThreadPool stp) | ||
41 | { | ||
42 | _associatedSmartThreadPool = stp; | ||
43 | _creationTime = DateTime.UtcNow; | ||
44 | _lastAliveTime = DateTime.MinValue; | ||
45 | } | ||
46 | |||
47 | public SmartThreadPool AssociatedSmartThreadPool | ||
48 | { | ||
49 | get { return _associatedSmartThreadPool; } | ||
50 | } | ||
51 | |||
52 | public void IAmAlive() | ||
53 | { | ||
54 | _lastAliveTime = DateTime.UtcNow; | ||
55 | } | ||
56 | } | ||
57 | |||
58 | #endregion | ||
59 | } | ||
60 | } \ No newline at end of file | ||