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
This commit is contained in:
parent
1a215987ac
commit
54d82e9659
|
@ -19,10 +19,10 @@ License along with this library
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace Nuclex.Support {
|
namespace Nuclex.Support {
|
||||||
|
|
||||||
|
@ -88,7 +88,11 @@ namespace Nuclex.Support {
|
||||||
// as we may run into situations where multiple operations need to be atomic.
|
// 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
|
// We keep track of the threads we've created just for good measure; not actually
|
||||||
// needed for any core functionality.
|
// needed for any core functionality.
|
||||||
|
#if XBOX360
|
||||||
workAvailable = new Semaphore();
|
workAvailable = new Semaphore();
|
||||||
|
#else
|
||||||
|
workAvailable = new System.Threading.Semaphore(0, Processors);
|
||||||
|
#endif
|
||||||
userWorkItems = new Queue<UserWorkItem>(Processors * 4);
|
userWorkItems = new Queue<UserWorkItem>(Processors * 4);
|
||||||
workerThreads = new List<Thread>(Processors);
|
workerThreads = new List<Thread>(Processors);
|
||||||
inUseThreads = 0;
|
inUseThreads = 0;
|
||||||
|
@ -299,7 +303,11 @@ namespace Nuclex.Support {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to let the threads in the thread pool wait for new work to appear.
|
/// Used to let the threads in the thread pool wait for new work to appear.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
#if XBOX360
|
||||||
private static Semaphore workAvailable;
|
private static Semaphore workAvailable;
|
||||||
|
#else
|
||||||
|
private static System.Threading.Semaphore workAvailable;
|
||||||
|
#endif
|
||||||
/// <summary>List of all worker threads at the disposal of the thread pool.</summary>
|
/// <summary>List of all worker threads at the disposal of the thread pool.</summary>
|
||||||
private static List<Thread> workerThreads;
|
private static List<Thread> workerThreads;
|
||||||
/// <summary>Number of threads currently active.</summary>
|
/// <summary>Number of threads currently active.</summary>
|
||||||
|
|
|
@ -99,13 +99,13 @@ namespace Nuclex.Support.Parsing {
|
||||||
|
|
||||||
/// <summary>Initializes a new command line</summary>
|
/// <summary>Initializes a new command line</summary>
|
||||||
/// <param name="argumentList">List containing the parsed arguments</param>
|
/// <param name="argumentList">List containing the parsed arguments</param>
|
||||||
private CommandLine(List<Argument> argumentList) :
|
private CommandLine(IList<Argument> argumentList) :
|
||||||
this(argumentList, WindowsModeDefault) { }
|
this(argumentList, WindowsModeDefault) { }
|
||||||
|
|
||||||
/// <summary>Initializes a new command line</summary>
|
/// <summary>Initializes a new command line</summary>
|
||||||
/// <param name="argumentList">List containing the parsed arguments</param>
|
/// <param name="argumentList">List containing the parsed arguments</param>
|
||||||
/// <param name="windowsMode">Whether the / character initiates an argument</param>
|
/// <param name="windowsMode">Whether the / character initiates an argument</param>
|
||||||
private CommandLine(List<Argument> argumentList, bool windowsMode) {
|
private CommandLine(IList<Argument> argumentList, bool windowsMode) {
|
||||||
this.arguments = argumentList;
|
this.arguments = argumentList;
|
||||||
this.windowsMode = windowsMode;
|
this.windowsMode = windowsMode;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ namespace Nuclex.Support.Parsing {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Options that were specified on the command line</summary>
|
/// <summary>Options that were specified on the command line</summary>
|
||||||
private List<Argument> arguments;
|
private IList<Argument> arguments;
|
||||||
/// <summary>Whether the / character initiates an argument</summary>
|
/// <summary>Whether the / character initiates an argument</summary>
|
||||||
private bool windowsMode;
|
private bool windowsMode;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,10 @@ using NUnit.Framework;
|
||||||
namespace Nuclex.Support {
|
namespace Nuclex.Support {
|
||||||
|
|
||||||
/// <summary>Unit Test for the Semaphore class</summary>
|
/// <summary>Unit Test for the Semaphore class</summary>
|
||||||
[TestFixture]
|
[
|
||||||
|
TestFixture,
|
||||||
|
Obsolete("Not obsolete, but prevents warning when using custom Semaphore on Windows")
|
||||||
|
]
|
||||||
public class SemaphoreTest {
|
public class SemaphoreTest {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -56,6 +56,9 @@ namespace Nuclex.Support {
|
||||||
/// become eligible for execution.
|
/// become eligible for execution.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
#if !XBOX360
|
||||||
|
[Obsolete("Prefer the normal semaphore on Windows builds.")]
|
||||||
|
#endif
|
||||||
public class Semaphore : WaitHandle {
|
public class Semaphore : WaitHandle {
|
||||||
|
|
||||||
/// <summary>Initializes a new semaphore</summary>
|
/// <summary>Initializes a new semaphore</summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user