public ReplayScheduler(ITimer timer, IReplayScenarioHandler scenarioHandler, IReplayDataReader dataReader, IThreadPoolCounter counter, double speedMultiplier, int threadId) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } if (scenarioHandler == null) { throw new ArgumentNullException(nameof(scenarioHandler)); } if (dataReader == null) { throw new ArgumentNullException(nameof(dataReader)); } if (counter == null) { throw new ArgumentNullException(nameof(counter)); } if (speedMultiplier <= 0) { throw new ArgumentException("speedMultiplier must be above 0", nameof(speedMultiplier)); } _timer = timer; _scenarioHandler = scenarioHandler; _dataReader = dataReader; _counter = counter; _speedMultiplier = speedMultiplier; _threadId = threadId; _waiter = new SemiWait(timer); }
public ReplaySchedulerFactory(ITimer timer, IReplayDataReader dataReader, IThreadPoolCounter counter, double speedMultiplier) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } if (dataReader == null) { throw new ArgumentNullException(nameof(dataReader)); } if (counter == null) { throw new ArgumentNullException(nameof(counter)); } _timer = timer; _dataReader = dataReader; _counter = counter; _speedMultiplier = speedMultiplier; }
public virtual ITestState Start() { _threadPoolCounter = new ThreadPoolCounter(); _globalCounters = GlobalCounters.CreateDefault(); ITestState testState = new TestState(_timer, _globalCounters, _threadPoolCounter); PipeFactory <IResult> pipeFactory = new PipeFactory <IResult>(); _aggregator = new PipelineDataAggregator(_settings.Aggregators, pipeFactory); _aggregator.Start(); _errorHandler = new ErrorHandler(); _dataReader = _settings.DataReader; _dataReader.Begin(testState); IIterationContextFactory iterationContextFactory = CreateIterationContextFactory(); IReplayScenarioHandlerFactory scenarioHandlerFactory = CreateScenarioHandlerFactory(); IReplaySchedulerFactory schedulerFactory = CreateSchedulerFactory(); IDataCollectorFactory dataCollectorFactory = CreateDataCollectorFactory(pipeFactory, _threadPoolCounter); IScenarioThreadFactory scenarioThreadFactory = CreateScenarioThreadFactory(); IThreadFactory threadFactory = new ReplayScenarioThreadFactory( iterationContextFactory, scenarioHandlerFactory, schedulerFactory, dataCollectorFactory, scenarioThreadFactory ); _pool = new ThreadPool(threadFactory, _threadPoolCounter); _pool.StartWorkersAsync(_settings.ThreadCount); while (_threadPoolCounter.CreatedThreadCount != _threadPoolCounter.InitializedThreadCount) { Thread.Sleep(100); _errorHandler.Assert(); } _timer.Start(); // This line also releases Worker-Threads from wait in IPrewait return(testState); }
/// <summary> /// Set custom data source for ReplayScenario /// </summary> /// <param name="dataReader"></param> /// <returns></returns> public ReplayStrategyBuilder <TData> SetData(IReplayDataReader dataReader) { DataReader = dataReader; return(this); }
public static DataItem Next(this IReplayDataReader reader, int threadId) { bool fakeRefStop = false; return(reader.Next(threadId, ref fakeRefStop)); }