diff options
author | Justin Clark-Casey (justincc) | 2013-05-01 19:01:43 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-05-01 19:01:43 +0100 |
commit | 206fb306a7820cf593570e35ddfa8e7c5a10e449 (patch) | |
tree | 0ef0fdf42ddc0b63224af52b62b0bad42f62e352 /ThirdParty/SmartThreadPool/SmartThreadPool.ThreadEntry.cs | |
parent | Fix CAPS to work like they should - do not send caps to the viewer if they're... (diff) | |
download | opensim-SC-206fb306a7820cf593570e35ddfa8e7c5a10e449.zip opensim-SC-206fb306a7820cf593570e35ddfa8e7c5a10e449.tar.gz opensim-SC-206fb306a7820cf593570e35ddfa8e7c5a10e449.tar.bz2 opensim-SC-206fb306a7820cf593570e35ddfa8e7c5a10e449.tar.xz |
Update SmartThreadPool to latest version 2.2.3 with a major and minor change.
SmartThreadPool code comes from http://www.codeproject.com/Articles/7933/Smart-Thread-Pool
This version implements thread abort (via WorkItem.Cancel(true)), threadpool naming, max thread stack, etc. so we no longer need to manually patch those.
However, two changes have been made to stock 2.2.3.
Major change: WorkItem.Cancel(bool abortExecution) in our version does not succeed if the work item was in progress and thread abort was not specified.
This is to match previous behaviour where we handle co-operative termination via another mechanism rather than checking WorkItem.IsCanceled.
Minor change: Did not add STP's StopWatch implementation as this is only used WinCE and Silverlight and causes a build clash with System.Diagnostics.StopWatch
The reason for updating is to see if this improves http://opensimulator.org/mantis/view.php?id=6557 and http://opensimulator.org/mantis/view.php?id=6586
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 | ||