diff --git a/src/Managed/Threading/Parallel.cs b/src/Managed/Threading/Parallel.cs index 67ad5fff..378ade6d 100644 --- a/src/Managed/Threading/Parallel.cs +++ b/src/Managed/Threading/Parallel.cs @@ -124,7 +124,7 @@ namespace MathNet.Numerics.Threading // wait until all jobs have completed if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA) { - //not sure if this the best approach for STA + // not sure if this the best approach for STA for (int i = 0; i < tasks.Length; i++) { tasks[i].WaitOne(); @@ -144,7 +144,7 @@ namespace MathNet.Numerics.Threading exceptions.Add(task.Exception); } - //this calls dispose + // this calls dispose task.Close(); } diff --git a/src/Managed/Threading/ThreadQueue.cs b/src/Managed/Threading/ThreadQueue.cs index 2545a678..8e48f6de 100644 --- a/src/Managed/Threading/ThreadQueue.cs +++ b/src/Managed/Threading/ThreadQueue.cs @@ -48,19 +48,19 @@ namespace MathNet.Numerics.Threading private static readonly object _queueSync = new object(); /// - /// Maximum number of jobs that can be in the queue at the same time. + /// Queue holding the pending jobs. /// - private const int _maximumQueueLength = 1024; + private static readonly Queue _queue = new Queue(); /// - /// Counting Semaphore to make the worker thread wait for jobs + /// Maximum number of jobs that can be in the queue at the same time. /// - private static Semaphore _tasksAvailableSemaphore; + private const int MaximumQueueLength = 1024; /// - /// Queue holding the pending jobs. + /// Counting Semaphore to make the worker thread wait for jobs /// - private static readonly Queue _queue = new Queue(); + private static Semaphore _tasksAvailableSemaphore; /// /// Running flag, used to signal worker threads to stop cleanly. @@ -73,12 +73,12 @@ namespace MathNet.Numerics.Threading private static Thread[] _threads; /// - /// Number of worked threads. + /// Gets the number of worker threads. /// internal static int ThreadCount { get; private set; } /// - /// Static Constructor + /// Initializes static members of the ThreadQueue class. /// static ThreadQueue() { @@ -92,12 +92,12 @@ namespace MathNet.Numerics.Threading /// The job to run. internal static void Enqueue(Task task) { - if(!_running) + if (!_running) { Start(); } - lock(_queueSync) + lock (_queueSync) { _queue.Enqueue(task); } @@ -111,14 +111,14 @@ namespace MathNet.Numerics.Threading /// The jobs to run. internal static void Enqueue(IList tasks) { - if(!_running) + if (!_running) { Start(); } - lock(_queueSync) + lock (_queueSync) { - foreach(var task in tasks) + foreach (var task in tasks) { _queue.Enqueue(task); } @@ -138,7 +138,7 @@ namespace MathNet.Numerics.Threading _tasksAvailableSemaphore.WaitOne(); // Check whether we should shut down - if(!_running) + if (!_running) { _tasksAvailableSemaphore.Release(); break; @@ -148,7 +148,7 @@ namespace MathNet.Numerics.Threading Task task = null; lock (_queueSync) { - if(_queue.Count > 0) + if (_queue.Count > 0) { task = _queue.Dequeue(); } @@ -163,6 +163,10 @@ namespace MathNet.Numerics.Threading } } + /// + /// Start or restart the queue with the specified number of worker threads. + /// + /// Number of worker threads. internal static void Start(int numberOfThreads) { lock (_stateSync) @@ -182,6 +186,9 @@ namespace MathNet.Numerics.Threading } } + /// + /// Start the thread queue, if it is not already running. + /// internal static void Start() { lock (_stateSync) @@ -191,7 +198,7 @@ namespace MathNet.Numerics.Threading return; } - _tasksAvailableSemaphore = new Semaphore(_queue.Count, _maximumQueueLength); + _tasksAvailableSemaphore = new Semaphore(_queue.Count, MaximumQueueLength); _running = true; _threads = new Thread[ThreadCount]; @@ -207,6 +214,9 @@ namespace MathNet.Numerics.Threading } } + /// + /// Stop the thread queue, if it is running. + /// internal static void Shutdown() { lock (_stateSync) diff --git a/src/Settings.Resharper.xml b/src/Settings.Resharper.xml index 5611929d..750a493a 100644 --- a/src/Settings.Resharper.xml +++ b/src/Settings.Resharper.xml @@ -1,4 +1,747 @@ + + + + + + en-US + false + Wikipedia +Cholesky +outplace +Inplace +diff +imag + + + + en-US + en-US + en-US + + en-US + + + Public Protected ProtectedInternal + Any + Maybe + Maybe + Any + + + + false + 80 + + + + + false + + + Any + Class + Maybe + Maybe + Any + + + Any + Enum + + Maybe + Maybe + Any + + + Any + EnumerationMember + + Maybe + Maybe + Any + + + + Classes, Enumerations, Enumeration values should be named in Pascal + + + _ + m_ + + Pascal + + + + + false + + + Public Internal Protected ProtectedInternal + Property + + Maybe + Maybe + Any + + + Public Internal Protected ProtectedInternal + Method + + Maybe + Maybe + Any + + + Public Internal Protected ProtectedInternal + Event + + Maybe + Maybe + Any + + + + Non private properties, methods, events should be in pascal. + + + _ + m_ + + Pascal + + + + + false + + + Private + Property + + Maybe + Maybe + Any + + + Private + Method + + Maybe + Maybe + Any + + + Private + Event + + Maybe + Maybe + Any + + + + Private properties, methods, events should be in pascal. + + + _ + m_ + + Pascal + + + + + false + + + Any + Field + + Maybe + Maybe + Any + + + + Fields should be underscore camel. + + _ + + + m_ + + Camel + + + + + false + + + Any + Variable + Maybe + Maybe + Any + + + Variable should be declared in camel. + + + _ + m_ + + Camel + + + + + false + + + Any + Parameter + Maybe + Maybe + Any + + + Function parameters should be in camel. + + + _ + m_ + + Camel + + + + + false + + + Any + Namespace + Maybe + Maybe + Any + + + Namespaces should be in Pascal. + + + _ + m_ + + Pascal + + + + + true + + + Any + Constant + Maybe + Maybe + Any + + + Constants should be in capital. + + + UpperCase + + + + + false + + + Any + Any + Maybe + Maybe + Any + + + + + Any + Constant + Maybe + Maybe + Any + + + Acronyms should not have more than 2 characters. + + + MatchesRegex + + + ^(?>(XML|SQL|[A-Z]{0,2})[A-Z]?([^A-Z]|$)|[^A-Z]+)*$ + + + false + + + Any + Any + Maybe + Maybe + Any + + + + + Any + Constant + + Maybe + Maybe + Any + + + Any + Field + + Maybe + Maybe + Any + + + Private + Method + + Maybe + Maybe + Any + + + None + Namespace + Maybe + Maybe + Any + + + Names should not have underscore character + + + NotMatchesRegex + + + (?<remove>_) + + + false + + + Any + Class + NUnit.Framework.TestFixtureAttribute + Maybe + Maybe + Any + + + TestFixtures should end with Test. + + + Test + + None + + Test + + + + + false + + + Any + Method + NUnit.Framework.TestAttribute + Maybe + Maybe + Any + + + Test methods should start with Test. + + Test + + + None + + + Test + + + + false + + + Any + Enum + Maybe + Maybe + Any + + + Enumerations should not end with Enum. + + + None + + + Enum + + + + false + + + Any + EnumerationMember + Maybe + Maybe + Any + + + Do not name enumerations reserved. + + + NotMatchesRegex + + + (?<remove>(reserved|Reserved)) + + + false + + + Any + Event + Maybe + Maybe + Any + + + Event should not have Before or After prefix. + + + Before + After + + None + + + + + false + + + Any + Enum + System.FlagsAttribute + Maybe + Maybe + Any + + + Flags enums should have plural names + + + None + + s + + + + + true + + + Any + Enum + Maybe + Maybe + Any + + + + + Any + Enum + System.FlagsAttribute + Maybe + Maybe + Any + + + Enums that are not flags should not have plural names + + + None + + + s + + + + false + + + Any + Class + System.Attribute + Maybe + Maybe + Any + + + Attribute should end with Attribute. + + + None + + Attribute + + + + + false + + + Any + Class + System.EventArgs + Maybe + Maybe + Any + + + EventArgs should end with EventArgs. + + + None + + EventArgs + + + + + false + + + Any + Class + System.Exception + Maybe + Maybe + Any + + + Exceptions should end with Exception. + + + None + + Exception + + + + + false + + + Any + Class + System.Collections.Stack + Maybe + Maybe + Any + + + Any + Class + System.Collections.Generic.Stack + + Maybe + Maybe + Any + + + + Stack should end with Collection or Stack. + + + None + + Collection + Stack + + + + + false + + + Any + Class + System.Collections.ICollection + Maybe + Maybe + Any + + + Any + Class + System.Collections.IEnumerable + Maybe + Maybe + Any + + + Any + Class + System.Collections.Generic.ICollection + Maybe + Maybe + Any + + + + + Any + Class + System.Collections.Stack + Maybe + Maybe + Any + + + Any + Class + System.Collections.Queue + Maybe + Maybe + Any + + + Any + Class + System.Collections.Generic.Stack + + Maybe + Maybe + Any + + + Collections should end with Collection. + + + None + + Collection + + + + + false + + + Any + Class + System.Collections.IDictionary + Maybe + Maybe + Any + + + Any + Class + System.Collections.Generic.IDictionary + Maybe + Maybe + Any + + + Dictionary should end with Dictionary. + + + None + + Dictionary + + + + + false + + + Any + Class + System.Collections.Queue + Maybe + Maybe + Any + + + Queue should end with Collection or Queue. + + + None + + Collection + Queue + + + + + false + + + Any + Interface + Maybe + Maybe + Any + + + Interfaces should be in Pascal and start with I. + + I + + + Pascal + + + + + + + + + Public Protected ProtectedInternal + Any + Maybe + Maybe + Any + + + + + (?#email)\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* + (?#url)http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)? + + + NEXT_LINE @@ -61,7 +804,7 @@ - + @@ -75,5 +818,8 @@ + + + \ No newline at end of file