コード例 #1
0
        public ReplayScenarioThreadFactory(IIterationContextFactory iterationContextFactory, IReplayScenarioHandlerFactory scenarioHandlerFactory, IReplaySchedulerFactory 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
ファイル: ReplayStrategy.cs プロジェクト: Vycka/LoadRunner
        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);
        }