void recycleEvent(Event* pEvent) { Lock lock(m_mutex); if (pEvent == m_Events + m_Head && m_Count > 0) { m_Head = incQueue(m_Head); m_Count--; lock.signal(m_space_available); } }
void* eventThreadMain() { gHub = new android::EventHub(); while(true) { Event event; bool result = gHub->getEvent(&event.deviceId, &event.type, &event.scancode, &event.keycode, &event.flags, &event.value, &event.when); if (result) { Lock lock(m_mutex); while( m_Count == MAX_EVENTS) { lock.wait(m_space_available); } m_Events[modQueue(m_Head + m_Count)] = event; m_Count = incQueue(m_Count); } } return NULL; }
// MAIN thread bool LLQueuedThread::addRequest(QueuedRequest* req) { if (mStatus == QUITTING) { return false; } lockData(); req->setStatus(STATUS_QUEUED); mRequestQueue.insert(req); mRequestHash.insert(req); #if _DEBUG // llinfos << llformat("LLQueuedThread::Added req [%08d]",handle) << llendl; #endif unlockData(); incQueue(); return true; }