-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestBoundChannel.cs
More file actions
40 lines (33 loc) · 1.43 KB
/
TestBoundChannel.cs
File metadata and controls
40 lines (33 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using ConcurrencyUtilities;
using System.Collections.Generic;
using System.Threading;
namespace TestConcurrencyUtilities
{
// Test my BoundChannel class
public class TestBoundChannel: TestChannelUtilities
{
static int _takeThreadsDelayTime;
public static void Run(int testMagnitude, int upperLimit, int sleepTime = 0) {
_testMagnitude = testMagnitude;
_sleepTime = sleepTime;
_channel = new BoundChannel<string>(upperLimit);
_takeThreadsDelayTime = _sleepTime * 5;
List<Thread> threads;
TestSupport.Log(ConsoleColor.Blue, "Bound channel test\n==============================");
TestSupport.Log(ConsoleColor.Blue, "\nBound channel size: " + upperLimit +
"\nThe take threads will start after a delay of " +
TestSupport.StringFromMilliseconds(_takeThreadsDelayTime));
Console.WriteLine("\nStarting Put threads...");
threads = TestSupport.CreateThreads(ChannelPut, "BoundChannelPutThread", _testMagnitude, 0);
threads.Add(new Thread(DelayChannelTakeThreads));
TestSupport.RunThreads(threads);
}
public static void DelayChannelTakeThreads() {
List<Thread> channelTakeThreads = TestSupport.CreateThreads(ChannelTake,
" BoundChannelTakeThread", _testMagnitude, 0);
TestSupport.SleepThread(_takeThreadsDelayTime, "\nWill shortly start Take threads...");
TestSupport.RunThreads(channelTakeThreads);
}
}
}