public CThread(int iterations, ThreadFunc func, object oParam, ITestOutputHelper output) { //Note: notice there are no "setters" on this class, so you can't reuse this class //for other thread functions, you need one class per thread function. This is exaclty //how the System.Thread class works, you can't reuse it, once the thread is complete, its done //so all the state set is for that thread... _rThread = new Thread(new ThreadStart(InternalThreadStart)); _threadfunc = func; _nIterations = iterations; _oParam = oParam; _output = output; }
public virtual void Add(int threads, int iterations, ThreadFunc func, object param) { for(int i=0; i<threads; i++) Add(new TestThread(iterations, func, param)); }
public virtual void Add(int threads, ThreadFunc func, object param) { //Default to one iteration Add(threads, 1, func, param); }
public virtual void Add(ThreadFunc func, object param) { Add(1, func, param); }
public TestThread(int iterations, ThreadFunc func, object param) { //Note: notice there are no "setters" on this class, so you can't reuse this class //for other thread functions, you need one class per thread function. This is exaclty //how the System.Thread class works, you can't reuse it, once the thread is complete, its done //so all the state set is for that thread... _thread = new Thread(new ThreadStart(InternalThreadStart)); _func = func; _iterations = iterations; _param = param; }
//Constructor public TestThread(ThreadFunc func, object param) : this(1, func, param) { //Default to 1 iteration }
//Constructor public CThread(ThreadFunc func, object oParam, ITestOutputHelper output) : this(1, func, oParam, output) { //Default to 1 iteration }
public void Add(int cThreads, int iterations, ThreadFunc func, object oParam) { for (int i = 0; i < cThreads; i++) Add(new CThread(iterations, func, oParam, _output)); }
public void Add(int cThreads, ThreadFunc func, object oParam) { //Default to one iteration Add(cThreads, 1, func, oParam); }
public void Add(ThreadFunc func, object oParam) { Add(1, func, oParam); }