示例#1
0
        public void Execute(string[] args)
        {
            using (OneOffComputation computation = NewComputation.FromArgs(ref args))
            {
                int numToExchange = args.Length > 1 ? int.Parse(args[1]) : 1000000;

                Stream <int, Epoch> input = computation.NewInput(new ConstantDataSource <int>(5));

                Stream <int, Epoch>           stream   = ProducerVertex.MakeStage(numToExchange, computation.Configuration.WorkerCount, input);
                Stage <ConsumerVertex, Epoch> consumer = ConsumerVertex.MakeStage(numToExchange, computation.Configuration.WorkerCount, stream);

                computation.Activate();
                computation.Join();
            }
        }
示例#2
0
        public void Execute(string[] args)
        {
            using (OneOffComputation computation = NewComputation.FromArgs(ref args))
            {
                int numToExchange = args.Length > 1 ? int.Parse(args[1]) : 1000000;
                int producers     = Int32.Parse(args[2]);
                int consumers     = Int32.Parse(args[3]);

                var exchange = args.Length > 4 && args[4] == "exchange";

                var input = new Pair <int, int>[] { }.AsNaiadStream(computation);

                Stream <Pair <int, int>, Epoch> stream = ProducerVertex.MakeStage(numToExchange, 0, producers, computation.Configuration.WorkerCount, input);
                Stage <ConsumerVertex, Epoch>   consumer = ConsumerVertex.MakeStage(numToExchange, computation.Configuration.Processes - consumers, computation.Configuration.Processes, computation.Configuration.WorkerCount, exchange, stream);

                computation.Activate();
                computation.Join();
            }
        }