void Script::abortAllThreads() { ScriptThreadList::iterator threadIterator; debug(3, "abortAllThreads()"); threadIterator = _threadList.begin(); while (threadIterator != _threadList.end()) { ScriptThread &thread = *threadIterator; thread._flags |= kTFlagAborted; ++threadIterator; } executeThreads(0); }
void Script::completeThread() { int limit = (_vm->getGameId() == GID_IHNM) ? 100 : 40; for (int i = 0; i < limit && !_threadList.empty(); i++) executeThreads(0); }
int main(int argc, char* argv[]) { char * string; string = buildString(); // string = "abcab"; // printf("STRING : %s\n",string); int state = 0; int state_amt = 4; int threadAmt; if(argc < 2 ) { threadAmt = 4; }else{ threadAmt = atoi(argv[1]); threadAmt = threadAmt+1; } // printf("threads = %d, states : %d string size : %d\n",threadAmt , state_amt, STRINGSIZE); // 1D : each thread // 2D : for each start state int states2[threadAmt][state_amt-1]; printf("START\n"); struct timeval start, end; gettimeofday(&start, NULL); // 10 executions int i; for(i = 0 ; i < 10 ; i++) { //executeThreads creates map in states2 states2[0][0] = 0; executeThreads(threadAmt, state_amt - 1 , states2, string); //initial state is states[0][0] as we start at 0th index on the 0th state state = states2[0][0]; //use mapping if(threadAmt > 1){ int i; for(i = 1 ; i < threadAmt ; i++) { //break if reject state if(state == REJECTSTATE) break; // -1 since the index is increased by 1 state = states2[i][state-1]; } } } gettimeofday(&end,NULL); printf("end state = %d\nelapsed time = %ld\n\n", state,((end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec))/1000); return 0; }