void EventHandler::start(lua_State *state) { while (stopHandler == false) { Glib::usleep(50000); if (timeout < 0.05) { // std::cout << "Resuming.." << std::endl; // TODO: Check event queue resumeThread(state); } else { timeout -= 0.05; if (!eventQueue.empty()) resumeThread(state); } } }
TcpReceiver::TcpReceiver(int port) : GuiFrame(0, 0) , CThread(CThread::eAttributeAffCore0 | CThread::eAttributePinnedAff) , exitRequested(false) , serverPort(port) , serverSocket(-1) , progressWindow("Receiving file...") { width = progressWindow.getWidth(); height = progressWindow.getHeight(); append(&progressWindow); resumeThread(); }
SoundHandler::SoundHandler() : CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x8000) { Decoding = false; ExitRequested = false; for(u32 i = 0; i < MAX_DECODERS; ++i) { DecoderList[i] = NULL; voiceList[i] = NULL; } resumeThread(); //! wait for initialization while(!isThreadSuspended()) usleep(1000); }
void MachineThreads::gatherFromOtherThread(ConservativeRoots& conservativeRoots, Thread* thread) { suspendThread(thread->platformThread); PlatformThreadRegisters regs; size_t regSize = getPlatformThreadRegisters(thread->platformThread, regs); conservativeRoots.add(static_cast<void*>(®s), static_cast<void*>(reinterpret_cast<char*>(®s) + regSize)); void* stackPointer = otherThreadStackPointer(regs); void* stackBase = thread->stackBase; swapIfBackwards(stackPointer, stackBase); conservativeRoots.add(stackPointer, stackBase); resumeThread(thread->platformThread); freePlatformThreadRegisters(regs); }
void MachineThreads::gatherConservativeRoots(ConservativeRoots& conservativeRoots, void* stackCurrent) { gatherFromCurrentThread(conservativeRoots, stackCurrent); if (m_threadSpecific) { PlatformThread currentPlatformThread = getCurrentPlatformThread(); MutexLocker lock(m_registeredThreadsMutex); #ifndef NDEBUG // Forbid malloc during the gather phase. The gather phase suspends // threads, so a malloc during gather would risk a deadlock with a // thread that had been suspended while holding the malloc lock. fastMallocForbid(); #endif for (Thread* thread = m_registeredThreads; thread; thread = thread->next) { if (!equalThread(thread->platformThread, currentPlatformThread)) suspendThread(thread->platformThread); } // It is safe to access the registeredThreads list, because we earlier asserted that locks are being held, // and since this is a shared heap, they are real locks. for (Thread* thread = m_registeredThreads; thread; thread = thread->next) { if (!equalThread(thread->platformThread, currentPlatformThread)) gatherFromOtherThread(conservativeRoots, thread); } for (Thread* thread = m_registeredThreads; thread; thread = thread->next) { if (!equalThread(thread->platformThread, currentPlatformThread)) resumeThread(thread->platformThread); } #ifndef NDEBUG fastMallocAllow(); #endif } }