From 54d82e965967639c8b1337a933234fc700d74d37 Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Wed, 1 Feb 2012 10:39:39 +0000 Subject: [PATCH] AffineThreadPool now uses standard semaphores in Windows builds; command line parser is satisfied with an IList of arguments instead of requiring a concrete List instance; added NCrunch XML file to svn:ignore list git-svn-id: file:///srv/devel/repo-conversion/nusu@222 d2e56fa2-650e-0410-a79f-9358c0239efd --- Source/AffineThreadPool.cs | 10 +++++++++- Source/Parsing/CommandLine.cs | 6 +++--- Source/Semaphore.Test.cs | 5 ++++- Source/Semaphore.cs | 3 +++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Source/AffineThreadPool.cs b/Source/AffineThreadPool.cs index 96512f5..1b2489d 100644 --- a/Source/AffineThreadPool.cs +++ b/Source/AffineThreadPool.cs @@ -19,10 +19,10 @@ License along with this library #endregion using System; -using System.Threading; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; +using System.Threading; namespace Nuclex.Support { @@ -88,7 +88,11 @@ namespace Nuclex.Support { // as we may run into situations where multiple operations need to be atomic. // We keep track of the threads we've created just for good measure; not actually // needed for any core functionality. +#if XBOX360 workAvailable = new Semaphore(); +#else + workAvailable = new System.Threading.Semaphore(0, Processors); +#endif userWorkItems = new Queue(Processors * 4); workerThreads = new List(Processors); inUseThreads = 0; @@ -299,7 +303,11 @@ namespace Nuclex.Support { /// /// Used to let the threads in the thread pool wait for new work to appear. /// +#if XBOX360 private static Semaphore workAvailable; +#else + private static System.Threading.Semaphore workAvailable; +#endif /// List of all worker threads at the disposal of the thread pool. private static List workerThreads; /// Number of threads currently active. diff --git a/Source/Parsing/CommandLine.cs b/Source/Parsing/CommandLine.cs index bb8213f..9662f99 100644 --- a/Source/Parsing/CommandLine.cs +++ b/Source/Parsing/CommandLine.cs @@ -99,13 +99,13 @@ namespace Nuclex.Support.Parsing { /// Initializes a new command line /// List containing the parsed arguments - private CommandLine(List argumentList) : + private CommandLine(IList argumentList) : this(argumentList, WindowsModeDefault) { } /// Initializes a new command line /// List containing the parsed arguments /// Whether the / character initiates an argument - private CommandLine(List argumentList, bool windowsMode) { + private CommandLine(IList argumentList, bool windowsMode) { this.arguments = argumentList; this.windowsMode = windowsMode; } @@ -298,7 +298,7 @@ namespace Nuclex.Support.Parsing { } /// Options that were specified on the command line - private List arguments; + private IList arguments; /// Whether the / character initiates an argument private bool windowsMode; diff --git a/Source/Semaphore.Test.cs b/Source/Semaphore.Test.cs index d1e8b68..cb44f38 100644 --- a/Source/Semaphore.Test.cs +++ b/Source/Semaphore.Test.cs @@ -29,7 +29,10 @@ using NUnit.Framework; namespace Nuclex.Support { /// Unit Test for the Semaphore class - [TestFixture] + [ + TestFixture, + Obsolete("Not obsolete, but prevents warning when using custom Semaphore on Windows") + ] public class SemaphoreTest { /// diff --git a/Source/Semaphore.cs b/Source/Semaphore.cs index 5c6e4f6..4f6b3e9 100644 --- a/Source/Semaphore.cs +++ b/Source/Semaphore.cs @@ -56,6 +56,9 @@ namespace Nuclex.Support { /// become eligible for execution. /// /// +#if !XBOX360 + [Obsolete("Prefer the normal semaphore on Windows builds.")] +#endif public class Semaphore : WaitHandle { /// Initializes a new semaphore