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); } } } }
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); } )); }
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); } )); }
public int Choose(int numChoices) { return(MChessChess.Choose(numChoices)); }
public static int Choose(int numChoices) { using (new WrapperSentry()) return(MChessChess.Choose(numChoices)); }