void FileInformation::runParse() { if(signalServer->enabled() && m_autoCheckFileUploaded) { QString statsFileName = fileName() + ".qctools.xml.gz"; QFileInfo fileInfo(statsFileName); checkFileUploaded(fileInfo.fileName()); } { int frameNumber = 1; for (;;) { if (Glue) { if (!Glue->NextFrame()) break; ++frameNumber; } if (WantToStop) break; yieldCurrentThread(); } } ActiveParsing_Count--; m_parsed = !WantToStop; Q_EMIT parsingCompleted(WantToStop == false); }
void MainServeur::Kick(QString Reason) { QByteArray paquet; QDataStream out(&paquet, QIODevice::WriteOnly); out << (quint16) 0; out << (quint8) SMSG_KICK; out << Reason; out.device()->seek(0); out << (quint16) (paquet.size() - sizeof(quint16)); ThreadSafe_WriteOnIODevice(m_Client, paquet); /** By Ryan Lahfa Bye bye my friend of network **/ yieldCurrentThread(); sleep(1); if(m_Client->state() != QAbstractSocket::UnconnectedState) { m_Client->waitForBytesWritten(); m_Client->disconnectFromHost(); } }
void EmuThread::run() { 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() || stop_run; }); } } render_window->moveContext(); }
void FileInformation::run() { if (blackmagicDeckLink_Glue) { blackmagicDeckLink_Glue->Glue=Glue; for (;;) { switch (blackmagicDeckLink_Glue->Config_Out.Status) { case BlackmagicDeckLink_Glue::instancied: blackmagicDeckLink_Glue->Start(); break; case BlackmagicDeckLink_Glue::finished: WantToStop=true; break; default : ; } if (WantToStop) break; yieldCurrentThread(); } delete blackmagicDeckLink_Glue; blackmagicDeckLink_Glue=NULL; } else { for (;;) { if (Glue) { if (!Glue->NextFrame()) break; } if (WantToStop) break; yieldCurrentThread(); } } ActiveParsing_Count--; }
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(); }
//! Entrypoint for LogThread //! Check to see if there are things to log and if so, write them to disk. //! Otherwise, wait 100ms and check again. //! Exit only when "go" is false AND all queued events are written void LogThread::run() { while(! actionLog.isEmpty() || go) { while(! actionLog.isEmpty()) { // Write all queued log entries lock.lockForRead(); LogEntry entry = actionLog.dequeue(); lock.unlock(); outStream << entry.dat.asInt << entry.position; ++logEntryCountByServo[entry.dat.asBitfield.servoIndex]; yieldCurrentThread(); } msleep(100); } exit(0); }
void ProcessingThread::run() { Mat orig, previmg, output, mask; vector<Point2f> prev_pts, orig_pts; vector<uchar> m_status; Mat m_error; TimerCreate(); while (isRunning()) { while (dh_in->ReadFrame(orig)) { TimerUpdate(); OpticalFlowHandle(previmg, orig, prev_pts, orig_pts); TimerElapsed(); } yieldCurrentThread(); } }
void QtOpenGLRenderThread::run() { ViewportSize viewportSize; bool suspended = false; m_ShuttingDown.store(false); // Initialize the renderer m_GL->context()->makeCurrent(); viewportSize.packed = m_ViewportSize.load(); m_Delegate->initializeGL(viewportSize.unpacked.width, viewportSize.unpacked.height); m_GL->context()->doneCurrent(); // Notify UI thread that we have started m_ThreadStartPromise.set_value(); // Run the main loop m_Timer.start(); while (!m_ShuttingDown.load(std::memory_order_relaxed)) { processAll(); // Consume less resources when suspended bool newSuspended = m_Suspended.load(); if (suspended && newSuspended) { yieldCurrentThread(); continue; } m_GL->context()->makeCurrent(); // Notify delegate about suspension if (newSuspended != suspended) { if (newSuspended) m_Delegate->suspendGL(); else { m_Delegate->resumeGL(); m_Timer.restart(); } suspended = newSuspended; } if (!suspended) { // Notify delegate about viewport size changes uint32_t newViewportSize = m_ViewportSize.load(); if (viewportSize.packed != newViewportSize) { viewportSize.packed = newViewportSize; m_Delegate->resizeGL(viewportSize.unpacked.width, viewportSize.unpacked.height); } // Run frame auto time = m_Timer.restart(); m_Delegate->renderGL(time * 0.001); m_GL->context()->swapBuffers(); } m_GL->context()->doneCurrent(); } // Shutdown the engine m_GL->context()->makeCurrent(); m_Delegate->shutdownGL(); m_GL->context()->doneCurrent(); }
void Thread::Yield() { yieldCurrentThread(); }