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++)); } } }
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); }
public Chef(Resteraunt resteraunt) { this.resteraunt = resteraunt; }