bool TaskThread::launch() { if (!init()) return false; _threadHandle = std::thread(&TaskThread::update, std::ref(*this)); #ifdef AGE_ENABLE_PROFILING MicroProfileOnThreadExit(); #endif return true; }
void EmuThread::run() { render_window->MakeCurrent(); MicroProfileOnThreadCreate("EmuThread"); stop_run = false; // holds whether the cpu was running during the last iteration, // so that the DebugModeLeft signal can be emitted before the // next execution step bool was_active = false; while (!stop_run) { if (running) { if (!was_active) emit DebugModeLeft(); Core::System::ResultStatus result = Core::System::GetInstance().RunLoop(); if (result != Core::System::ResultStatus::Success) { emit ErrorThrown(result, Core::System::GetInstance().GetStatusDetails()); } was_active = running || exec_step; if (!was_active && !stop_run) emit DebugModeEntered(); } else if (exec_step) { if (!was_active) emit DebugModeLeft(); exec_step = false; Core::System::GetInstance().SingleStep(); emit DebugModeEntered(); yieldCurrentThread(); was_active = false; } else { std::unique_lock<std::mutex> lock(running_mutex); running_cv.wait(lock, [this] { return IsRunning() || exec_step || stop_run; }); } } // Shutdown the core emulation Core::System::GetInstance().Shutdown(); #if MICROPROFILE_ENABLED MicroProfileOnThreadExit(); #endif render_window->moveContext(); }
int main() { MicroProfileSetForceEnable(true); MicroProfileOnThreadCreate("Main"); { MICROPROFILE_SCOPEI("Group", "Name", -1); MICROPROFILE_LABEL("Group", "Label"); MICROPROFILE_LABELF("Group", "Label %d", 5); } MicroProfileFlip(); MicroProfileOnThreadExit(); }
void EmuThread::run() { render_window->MakeCurrent(); MicroProfileOnThreadCreate("EmuThread"); stop_run = false; // holds whether the cpu was running during the last iteration, // so that the DebugModeLeft signal can be emitted before the // next execution step bool was_active = false; while (!stop_run) { if (running) { if (!was_active) emit DebugModeLeft(); Core::RunLoop(); was_active = running || exec_step; if (!was_active && !stop_run) emit DebugModeEntered(); } else if (exec_step) { if (!was_active) emit DebugModeLeft(); exec_step = false; Core::SingleStep(); emit DebugModeEntered(); yieldCurrentThread(); was_active = false; } else { std::unique_lock<std::mutex> lock(running_mutex); running_cv.wait(lock, [this]{ return IsRunning() || exec_step || stop_run; }); } } // Shutdown the core emulation System::Shutdown(); MicroProfileOnThreadExit(); render_window->moveContext(); }