private void PickUpFork(ActorRef fork) { if (this.LeftFork == fork) { Console.WriteLine("{0} has {1} in his left hand", this.Self.Name(), fork.Name()); this.OwnsLeftFork = true; } else if(this.RightFork == fork) { Console.WriteLine("{0} has {1} in his right hand", this.Self.Name(), fork.Name()); this.OwnsRightFork = true; } if ((!this.OwnsLeftFork || !this.OwnsRightFork) && (this.random.Next(1) == 1)) { this.DropFork(this.LeftFork); this.DropFork(this.RightFork); this.StartWaiting(); return; } this.StartEating(); }
private void AssignRightFork(ActorRef rightFork) { this.RightFork = rightFork; Console.WriteLine("{0} is using {1} as his right fork", this.Self.Name(), rightFork.Name()); }
private void AssignLeftFork(ActorRef leftFork) { this.LeftFork = leftFork; Console.WriteLine("{0} is using {1} as his left fork", this.Self.Name(), leftFork.Name()); }