private bool Run(CommandProcessorContext context, int threads, int tasks) { context.IsAsync(); var done = new AutoResetEvent(false); var coordinator = new Coordinator(context, _producers, tasks, done); coordinator.Start(); var workers = new Worker[threads]; for (var i = 0; i < workers.Length; i++) workers[i] = new Worker(i.ToString(), coordinator, context.Client.Options.WriteWindow); foreach (var worker in workers) worker.Start(); done.WaitOne(); foreach (var worker in workers) worker.Stop(); context.Success(); return true; }
private bool Run(CommandProcessorContext context, int writers, int readers, int events) { context.IsAsync(); var created = new AutoResetEvent(false); var done = new AutoResetEvent(false); var coordinator = new Coordinator(context, Producers, events,created, done); coordinator.Start(); var verificationWorkers = new VerificationWorker[readers]; for (int i = 0; i < verificationWorkers.Length; i++) verificationWorkers[i] = new VerificationWorker(string.Format("verifier {0}", i), coordinator, context.Client.Options.ReadWindow); var writerWrokers = new WriteWorker[writers]; for (int i = 0; i < writerWrokers.Length; i++) writerWrokers[i] = new WriteWorker(string.Format("writer {0}", i), coordinator, context.Client.Options.WriteWindow); foreach (var worker in verificationWorkers) worker.Start(); foreach (var worker in writerWrokers) worker.Start(); created.WaitOne(); done.WaitOne(); foreach (var worker in verificationWorkers) worker.Stop(); foreach (var worker in writerWrokers) worker.Stop(); context.Success(); return true; }