Ejemplo n.º 1
0
        private static void TheAtomicCafe()
        {
            Resteraunt resteraunt = new Resteraunt(2);

            Waiter waiter = new Waiter(resteraunt);



            ConsoleKey key;
            Chef       chef = new Chef(resteraunt);
            int        id   = 1;

            while ((key = Console.ReadKey(true).Key) != ConsoleKey.Q)
            {
                if (key == ConsoleKey.C)
                {
                    chef.MakeFoodAsync();
                }

                if (key == ConsoleKey.N)
                {
                    resteraunt.Customers.Post(new Customer(id++));
                }
            }
        }
Ejemplo n.º 2
0
        public Waiter(Resteraunt resteraunt)
        {
            this.resteraunt = resteraunt;
            joinBlock       = new JoinBlock <Tuple <Fork, Knife, Food>, Customer>(new GroupingDataflowBlockOptions()
            {
                Greedy = false
            });

            resteraunt.ReadyToGo.LinkTo(joinBlock.Target1);
            resteraunt.Customers.LinkTo(joinBlock.Target2);

            serveFoodBlock = new ActionBlock <Tuple <Tuple <Fork, Knife, Food>, Customer> >(
                new Action <Tuple <Tuple <Fork, Knife, Food>, Customer> >(ServeFood));

            joinBlock.LinkTo(serveFoodBlock);
        }
Ejemplo n.º 3
0
 public Chef(Resteraunt resteraunt)
 {
     this.resteraunt = resteraunt;
 }