示例#1
0
        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();
        }
示例#2
0
 private void AssignRightFork(ActorRef rightFork)
 {
     this.RightFork = rightFork;
     Console.WriteLine("{0} is using {1} as his right fork", this.Self.Name(), rightFork.Name());
 }
示例#3
0
 private void AssignLeftFork(ActorRef leftFork)
 {
     this.LeftFork = leftFork;
     Console.WriteLine("{0} is using {1} as his left fork", this.Self.Name(), leftFork.Name());
 }