예제 #1
0
        public bool TryExecuteTaskInline(Task task, bool wasQueuedBefore)
        {
            int choice = MChessChess.Choose(2);

            if (choice == 0)
            {
                return(false);
            }
            else
            {
                if (!wasQueuedBefore)
                {
                    task.Execute();
                    return(true);
                }
                else
                {
                    bool canceled = TryDequeue(task);
                    if (canceled)
                    {
                        task.Execute();
                        return(true);
                    }
                    else
                    {
                        // task has already been executed
                        return(false);
                    }
                }
            }
        }
예제 #2
0
 static internal int ChooseWildcardReceiveToMatch(OMini::MiniMPIStringRuntime self, int[] wildRecvIdxs)
 {
     return(Helper.SimpleWrap <int>(
                delegate(ClrSyncManager manager)
     {
         // Don't match unless all our processes are blocked
         if (!self.AreAllProcessesBlocked())
         {
             return -1;
         }
         // let CHESS choose for us
         return wildRecvIdxs[MChessChess.Choose(wildRecvIdxs.Length)];
     },
                delegate() {
         // Don't match unless all our processes are blocked
         if (!self.AreAllProcessesBlocked())
         {
             return -1;
         }
         return self.ChooseWildcardReceiveToMatch(wildRecvIdxs);
     }
                ));
 }
예제 #3
0
 static internal int ChooseSendToMatchWithWildcardReceive(OMini::MiniMPIStringRuntime self, List <int> sendInstrIdxs)
 {
     return(Helper.SimpleWrap <int>(
                delegate(ClrSyncManager manager)
     {
         // Don't match unless all our processes are blocked
         if (!self.AreAllProcessesBlocked())
         {
             return -1;
         }
         // let CHESS choose for us
         return sendInstrIdxs[MChessChess.Choose(sendInstrIdxs.Count)];
     },
                delegate()
     {
         // Don't match unless all our processes are blocked
         if (!self.AreAllProcessesBlocked())
         {
             return -1;
         }
         return self.ChooseSendToMatchWithWildcardReceive(sendInstrIdxs);
     }
                ));
 }
예제 #4
0
 public int Choose(int numChoices)
 {
     return(MChessChess.Choose(numChoices));
 }
예제 #5
0
파일: API.cs 프로젝트: sahilagnihotri/Chess
 public static int Choose(int numChoices)
 {
     using (new WrapperSentry())
         return(MChessChess.Choose(numChoices));
 }