From 206fb306a7820cf593570e35ddfa8e7c5a10e449 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 1 May 2013 19:01:43 +0100 Subject: 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 --- .../SmartThreadPool/SynchronizedDictionary.cs | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 ThirdParty/SmartThreadPool/SynchronizedDictionary.cs (limited to 'ThirdParty/SmartThreadPool/SynchronizedDictionary.cs') diff --git a/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs b/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs new file mode 100644 index 0000000..3532cca --- /dev/null +++ b/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs @@ -0,0 +1,89 @@ +using System.Collections.Generic; + +namespace Amib.Threading.Internal +{ + internal class SynchronizedDictionary + { + private readonly Dictionary _dictionary; + private readonly object _lock; + + public SynchronizedDictionary() + { + _lock = new object(); + _dictionary = new Dictionary(); + } + + public int Count + { + get { return _dictionary.Count; } + } + + public bool Contains(TKey key) + { + lock (_lock) + { + return _dictionary.ContainsKey(key); + } + } + + public void Remove(TKey key) + { + lock (_lock) + { + _dictionary.Remove(key); + } + } + + public object SyncRoot + { + get { return _lock; } + } + + public TValue this[TKey key] + { + get + { + lock (_lock) + { + return _dictionary[key]; + } + } + set + { + lock (_lock) + { + _dictionary[key] = value; + } + } + } + + public Dictionary.KeyCollection Keys + { + get + { + lock (_lock) + { + return _dictionary.Keys; + } + } + } + + public Dictionary.ValueCollection Values + { + get + { + lock (_lock) + { + return _dictionary.Values; + } + } + } + public void Clear() + { + lock (_lock) + { + _dictionary.Clear(); + } + } + } +} -- cgit v1.1 From 854dcd1abddc3eef33da953592deb61133e5e7ed Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 1 May 2013 23:00:46 +0100 Subject: Fix SmartThreadPool line endings in recent update from dos to unix --- .../SmartThreadPool/SynchronizedDictionary.cs | 178 ++++++++++----------- 1 file changed, 89 insertions(+), 89 deletions(-) (limited to 'ThirdParty/SmartThreadPool/SynchronizedDictionary.cs') diff --git a/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs b/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs index 3532cca..0cce19f 100644 --- a/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs +++ b/ThirdParty/SmartThreadPool/SynchronizedDictionary.cs @@ -1,89 +1,89 @@ -using System.Collections.Generic; - -namespace Amib.Threading.Internal -{ - internal class SynchronizedDictionary - { - private readonly Dictionary _dictionary; - private readonly object _lock; - - public SynchronizedDictionary() - { - _lock = new object(); - _dictionary = new Dictionary(); - } - - public int Count - { - get { return _dictionary.Count; } - } - - public bool Contains(TKey key) - { - lock (_lock) - { - return _dictionary.ContainsKey(key); - } - } - - public void Remove(TKey key) - { - lock (_lock) - { - _dictionary.Remove(key); - } - } - - public object SyncRoot - { - get { return _lock; } - } - - public TValue this[TKey key] - { - get - { - lock (_lock) - { - return _dictionary[key]; - } - } - set - { - lock (_lock) - { - _dictionary[key] = value; - } - } - } - - public Dictionary.KeyCollection Keys - { - get - { - lock (_lock) - { - return _dictionary.Keys; - } - } - } - - public Dictionary.ValueCollection Values - { - get - { - lock (_lock) - { - return _dictionary.Values; - } - } - } - public void Clear() - { - lock (_lock) - { - _dictionary.Clear(); - } - } - } -} +using System.Collections.Generic; + +namespace Amib.Threading.Internal +{ + internal class SynchronizedDictionary + { + private readonly Dictionary _dictionary; + private readonly object _lock; + + public SynchronizedDictionary() + { + _lock = new object(); + _dictionary = new Dictionary(); + } + + public int Count + { + get { return _dictionary.Count; } + } + + public bool Contains(TKey key) + { + lock (_lock) + { + return _dictionary.ContainsKey(key); + } + } + + public void Remove(TKey key) + { + lock (_lock) + { + _dictionary.Remove(key); + } + } + + public object SyncRoot + { + get { return _lock; } + } + + public TValue this[TKey key] + { + get + { + lock (_lock) + { + return _dictionary[key]; + } + } + set + { + lock (_lock) + { + _dictionary[key] = value; + } + } + } + + public Dictionary.KeyCollection Keys + { + get + { + lock (_lock) + { + return _dictionary.Keys; + } + } + } + + public Dictionary.ValueCollection Values + { + get + { + lock (_lock) + { + return _dictionary.Values; + } + } + } + public void Clear() + { + lock (_lock) + { + _dictionary.Clear(); + } + } + } +} -- cgit v1.1