Example #1
0
 private void TryGetRightFork(int numPhil, ref ForksState forkState, Table table)
 {
     if (!table[numPhil].IsUse)
     {
         table[numPhil].IsUse = true;
         forkState            = ForksState.LeftRight;
         Table = table;
         //Debug.WriteLine("{0}  Philosopher № {1} Get Right Fork", DateTime.Now, numPhil);
     }
 }
Example #2
0
 internal void TryGetFork(int philosopherNumber, ref ForksState philosophForksState, Table table)
 {
     if (philosophForksState == ForksState.Empty)
     {
         if (GetPermissionToUseForks(table))
         {
             if (!table[_leftForkIndex].IsUse)
             {
                 table[_leftForkIndex].IsUse = true;
                 philosophForksState         = ForksState.Left;
                 Table = table;
                 //Debug.WriteLine("{0}  Philosopher № {1} Get Left Fork", DateTime.Now, philosopherNumber);
             }
         }
     }
     else
     {
         if (philosophForksState == ForksState.Left)
         {
             TryGetRightFork(philosopherNumber, ref philosophForksState, table);
         }
     }
 }
Example #3
0
 public PhilosopherEventArgs(ForksState forksState, PhilosopherState state, int number)
 {
     ForksState = forksState;
     Number     = number;
     State      = state;
 }