示例#1
0
        public ScenarioThreadFactory(IIterationContextFactory iterationContextFactory, IScenarioHandlerFactory scenarioHandlerFactory, ISchedulerFactory schedulerFactory, IDataCollectorFactory dataCollectorFactory, IScenarioThreadFactory threadFactory)
        {
            if (iterationContextFactory == null)
            {
                throw new ArgumentNullException(nameof(iterationContextFactory));
            }
            if (scenarioHandlerFactory == null)
            {
                throw new ArgumentNullException(nameof(scenarioHandlerFactory));
            }
            if (schedulerFactory == null)
            {
                throw new ArgumentNullException(nameof(schedulerFactory));
            }
            if (dataCollectorFactory == null)
            {
                throw new ArgumentNullException(nameof(dataCollectorFactory));
            }
            if (threadFactory == null)
            {
                throw new ArgumentNullException(nameof(threadFactory));
            }



            _iterationContextFactory = iterationContextFactory;
            _scenarioHandlerFactory  = scenarioHandlerFactory;
            _schedulerFactory        = schedulerFactory;
            _dataCollectorFactory    = dataCollectorFactory;
            _threadFactory           = threadFactory;
        }
示例#2
0
        public ITestState Start()
        {
            _threadPoolCounter = new ThreadPoolCounter();

            PipeFactory <IResult> pipeFactory = new PipeFactory <IResult>();

            _aggregator = new PipelineDataAggregator(_settings.Aggregators, pipeFactory);
            _aggregator.Start();

            _globalCounters = GlobalCounters.CreateDefault();

            _errorHandler = new ErrorHandler();

            _limit     = new LimitsHandler(_settings.Limits);
            _threading = _settings.Threading;

            _state = new TestState(_timer, _globalCounters, _threadPoolCounter);

            _speed = PriorityStrategyFactory.Create(_settings.Speeds, _timer);
            _speed.Setup(_state);

            IIterationContextFactory iterationContextFactory = CreateIterationContextFactory();
            IScenarioHandlerFactory  scenarioHandlerFactory  = CreateScenarioHandlerFactory();
            ISchedulerFactory        schedulerFactory        = CreateSchedulerFactory();
            IDataCollectorFactory    dataCollectorFactory    = CreateDataCollectorFactory(pipeFactory, _threadPoolCounter);
            IScenarioThreadFactory   scenarioThreadFactory   = CreateScenarioThreadFactory();

            IThreadFactory threadFactory = new ScenarioThreadFactory(
                iterationContextFactory,
                scenarioHandlerFactory,
                schedulerFactory,
                dataCollectorFactory,
                scenarioThreadFactory
                );

            _pool = new ThreadPool(threadFactory, _threadPoolCounter);

            InitialThreadingSetup();

            _timer.Start(); // This line also releases Worker-Threads from wait in IPrewait

            return(_state);
        }