Found the synchronization problem in the affine thread pool - the auto reset event was being set twice before even a single thread pool thread made it through the WaitOne() - fixed by using a semaphore; implemented a semaphore that should work in the XBox 360; wrote unit tests for said semaphore; added messages to the affine thread pool's unit tests to make debugging easier
git-svn-id: file:///srv/devel/repo-conversion/nusu@177 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
09247541f2
commit
874fe0a9e4
6 changed files with 381 additions and 10 deletions
|
|
@ -82,7 +82,7 @@ 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.
|
||||
workAvailable = new AutoResetEvent(false);
|
||||
workAvailable = new Semaphore();
|
||||
userWorkItems = new Queue<UserWorkItem>(CpuCores * 4);
|
||||
workerThreads = new List<Thread>(CpuCores);
|
||||
inUseThreads = 0;
|
||||
|
|
@ -144,7 +144,7 @@ namespace Nuclex.Support {
|
|||
}
|
||||
|
||||
// Wake up one of the worker threads so this task will be processed
|
||||
workAvailable.Set();
|
||||
workAvailable.Release();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ namespace Nuclex.Support {
|
|||
/// <summary>
|
||||
/// Used to let the threads in the thread pool wait for new work to appear.
|
||||
/// </summary>
|
||||
private static AutoResetEvent workAvailable;
|
||||
private static Semaphore workAvailable;
|
||||
/// <summary>List of all worker threads at the disposal of the thread pool.</summary>
|
||||
private static List<Thread> workerThreads;
|
||||
/// <summary>Number of threads currently active.</summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue