static void Emulator_run(JNIEnv *env, jobject self) { jEnv = env; pthread_mutex_init(&emuStateMutex, NULL); pthread_cond_init(&emuStateCond, NULL); while (true) { pthread_mutex_lock(&emuStateMutex); while (emuState == EMUSTATE_PAUSED) pthread_cond_wait(&emuStateCond, &emuStateMutex); if (emuState == EMUSTATE_QUIT) { pthread_mutex_unlock(&emuStateMutex); break; } if (emuState == EMUSTATE_REQUEST_RUN) { emuState = EMUSTATE_RUNNING; pthread_cond_signal(&emuStateCond); } pthread_mutex_unlock(&emuStateMutex); runEmulator(); pthread_mutex_lock(&emuStateMutex); if (emuState == EMUSTATE_REQUEST_PAUSE) { emuState = EMUSTATE_PAUSED; pthread_cond_signal(&emuStateCond); } pthread_mutex_unlock(&emuStateMutex); } }
static void *emuThreadProc(void *arg) { while (true) { pthread_mutex_lock(&emuStateMutex); while (emuState == EMUSTATE_PAUSED) pthread_cond_wait(&emuStateCond, &emuStateMutex); if (emuState == EMUSTATE_QUIT) { pthread_mutex_unlock(&emuStateMutex); break; } if (emuState == EMUSTATE_REQUEST_RUN) { emuState = EMUSTATE_RUNNING; pthread_cond_signal(&emuStateCond); } pthread_mutex_unlock(&emuStateMutex); runEmulator(); pthread_mutex_lock(&emuStateMutex); if (emuState == EMUSTATE_REQUEST_PAUSE) { emuState = EMUSTATE_PAUSED; pthread_cond_signal(&emuStateCond); } pthread_mutex_unlock(&emuStateMutex); } return NULL; }
void WorkerThread::run() { m_die = false; if(!m_die) runTest(); if(!m_die) runConfig(); if(!m_die) runUnzip(); if(!m_die) runEmulator(); if(!m_die) runRezip(); }
int main() { chip8 chip; initChip(&chip); requestRom(&chip); runEmulator(&chip); return 0; }