Example #1
0
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;
}
Example #2
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();
}
Example #3
0
static void memoryLoaded() {
	sSemaphore.post();
}
Example #4
0
static void errorCallback() {
	//TODO: set error state, so thread knows not to continue?
	sSemaphore.post();
	setErrorCallback(NULL);
}
Example #5
0
void stopUserThread() {
	run = false;
	sPause.post();
}
Example #6
0
void resumeUserInput() {
	sPause.post();
}