int SDLCALL userInputThreadFunc(void* arg) { istream* input = (istream*)arg; while(run) { DebuggerEvent* de = new DebuggerEvent; de->type = DebuggerEvent::eUserInput; getline(*input, de->str); while(!input->good()) { if(!input->eof()) { eprintf("Input fail! Exiting...\n"); return 1; } if(input != &cin) { //delete input; //not so good with multi-threading, maybe. input = &cin; getline(*input, de->str); } else { return 0; } } if(input != &cin) { eprintf("%s\n", de->str.c_str()); } putEvent(de); sPause.wait(); } return 0; }
void ExpressionCommon::loadMemory(int addr, int len) { if(addr == 0) ExpressionCommon::error("Trying to load memory from NULL"); DebuggerEvent *evnt = new DebuggerEvent; evnt->type = DebuggerEvent::eReadMemory; evnt->src = addr; evnt->len = len; evnt->rmcb = memoryLoaded; putEvent(evnt); sSemaphore.wait(); }
static void memoryLoaded() { sSemaphore.post(); }
static void errorCallback() { //TODO: set error state, so thread knows not to continue? sSemaphore.post(); setErrorCallback(NULL); }
void stopUserThread() { run = false; sPause.post(); }
void resumeUserInput() { sPause.post(); }