void RChannelItemReaderHandler:: ProcessItemArray(RChannelItemArray* deliveredArray) { if (deliveredArray->GetNumberOfItems() == 1) { RChannelItemRef* a = deliveredArray->GetItemArray(); ProcessItem(a[0]); } else { LogAssert(deliveredArray->GetNumberOfItems() == 0); ProcessItem(NULL); } }
void AbstractDistributor::ProcessActiveList() { itemListT::iterator it = activeList.begin(); while(it != activeList.end()) { ItemPtr pItem = *it; ProcessResult result = ProcessItem(pItem); if(result == DeleteItem) { it = activeList.erase(it); itemsCount--; } if (result == PauseProcessing) { inactiveList.push_back(pItem); it = activeList.erase(it); lastListChange =time(NULL); } if (result == ContinueProcessing) { it++; } // if (it == activeList.end()) { CheckMergeNewInsertedItems(); CheckMergeInactiveItems(); it = activeList.begin(); } } }
// ------------------------------------------------------------------- // InThread // ------------------------------------------------------------------- void ThreadManager::InThread() { boost::posix_time::milliseconds workTime(5); while (running) { boost::this_thread::sleep(workTime); if (running == false) break; if (!inHasQueuedItems) continue; boost::shared_ptr<map<string, boost::shared_ptr<void> > > item; inQueueLocker.lock(); while (inThreadQueue->size() > 0) { item = inThreadQueue->front(); inThreadQueue->pop_front(); ProcessItem(item); item->clear(); } inHasQueuedItems = false; inQueueLocker.unlock(); } }
void Validator::Validate(const vector<uint64_t>& instructions) { Done.clear(); Done.resize(instructions.size()); WorkItems.emplace_back(new state(0)); while (!WorkItems.empty()) { unique_ptr<state> item = move(WorkItems.back()); WorkItems.pop_back(); ProcessItem(instructions, *item); } }
bool ListTraveller<Item>::Traverse() { bool ret = false; for(m_iterator.First(); m_iterator.End(); m_iterator.Next()) { ret = ProcessItem(m_iterator.CurItem()); if(ret == false) break; } return ret; }
static void func() { while (true) { char* p = fgets(buf, 255, stdin); if (p == NULL) { return; } if (*p == '0') return; int len = strlen(buf); while (buf[len-1] == '\n' || buf[len - 1] == '\r') { buf[len-1] = 0; len--; if (len == 0) break; } ProcessItem(); } return; }
DWORD IconExtractorThread::Run() { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED/*COINIT_MULTITHREADED*/); while (myStatus == 0L) { IconExtractionData aDt; bool aEndOfList = myHost.GetNextItem(aDt); if (aEndOfList) { if ( !myHost.WaitForWorkerThreadResumption(200) ) break; else continue; // we will have to first check if we're not instructed to terminate and only then repeat icon processing } ProcessItem(aDt); } CoUninitialize(); return 0; }
UPnpCDSExtensionResults *UPnpCDSExtension::Browse( UPnpCDSRequest *pRequest ) { // -=>TODO: Need to add Filter & Sorting Support. // -=>TODO: Need to add Sub-Folder/Category Support!!!!! if (!IsBrowseRequestForUs( pRequest )) return( NULL ); // ---------------------------------------------------------------------- // Parse out request object's path // ---------------------------------------------------------------------- QStringList idPath = QStringList::split( "/", pRequest->m_sObjectId.section('=',0,0) ); QString key = pRequest->m_sObjectId.section('=',1); if (idPath.count() == 0) return( NULL ); // ---------------------------------------------------------------------- // Process based on location in hierarchy // ---------------------------------------------------------------------- UPnpCDSExtensionResults *pResults = new UPnpCDSExtensionResults(); if (pResults != NULL) { if (key) idPath.last().append(QString("=%1").arg(key)); else { if (pRequest->m_sObjectId.contains("item")) { idPath = QStringList::split( " ", idPath[idPath.count() - 2] ); idPath = QStringList::split( "?", idPath[0] ); idPath = idPath[0]; if (idPath[0].startsWith("Id")) idPath[0] = QString("item=%1").arg(idPath[0].right(idPath[0].length() - 2)); } } QString sLast = idPath.last(); pRequest->m_sParentId = pRequest->m_sObjectId; if (sLast == m_sExtensionId ) { return( ProcessRoot ( pRequest, pResults, idPath )); } if (sLast == "0" ) { return( ProcessAll ( pRequest, pResults, idPath )); } if (sLast.startsWith( "key" , true )) { return( ProcessKey ( pRequest, pResults, idPath )); } if (sLast.startsWith( "item", true )) { return( ProcessItem ( pRequest, pResults, idPath )); } int nNodeIdx = sLast.toInt(); if ((nNodeIdx > 0) && (nNodeIdx < GetRootCount())) return( ProcessContainer( pRequest, pResults, nNodeIdx, idPath )); pResults->m_eErrorCode = UPnPResult_CDS_NoSuchObject; pResults->m_sErrorDesc = ""; } return( pResults ); }
void CGUIBaseContainer::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) { // update our auto-scrolling as necessary UpdateAutoScrolling(currentTime); ValidateOffset(); if (m_bInvalidated) UpdateLayout(); if (!m_layout || !m_focusedLayout) return; UpdateScrollOffset(currentTime); int offset = (int)floorf(m_scroller.GetValue() / m_layout->Size(m_orientation)); int cacheBefore, cacheAfter; GetCacheOffsets(cacheBefore, cacheAfter); // Free memory not used on screen if ((int)m_items.size() > m_itemsPerPage + cacheBefore + cacheAfter) FreeMemory(CorrectOffset(offset - cacheBefore, 0), CorrectOffset(offset + m_itemsPerPage + 1 + cacheAfter, 0)); CPoint origin = CPoint(m_posX, m_posY) + m_renderOffset; float pos = (m_orientation == VERTICAL) ? origin.y : origin.x; float end = (m_orientation == VERTICAL) ? m_posY + m_height : m_posX + m_width; // we offset our draw position to take into account scrolling and whether or not our focused // item is offscreen "above" the list. float drawOffset = (offset - cacheBefore) * m_layout->Size(m_orientation) - m_scroller.GetValue(); if (GetOffset() + GetCursor() < offset) drawOffset += m_focusedLayout->Size(m_orientation) - m_layout->Size(m_orientation); pos += drawOffset; end += cacheAfter * m_layout->Size(m_orientation); int current = offset - cacheBefore; while (pos < end && m_items.size()) { int itemNo = CorrectOffset(current, 0); if (itemNo >= (int)m_items.size()) break; bool focused = (current == GetOffset() + GetCursor()); if (itemNo >= 0) { CGUIListItemPtr item = m_items[itemNo]; // render our item if (m_orientation == VERTICAL) ProcessItem(origin.x, pos, item, focused, currentTime, dirtyregions); else ProcessItem(pos, origin.y, item, focused, currentTime, dirtyregions); } // increment our position pos += focused ? m_focusedLayout->Size(m_orientation) : m_layout->Size(m_orientation); current++; } // when we are scrolling up, offset will become lower (integer division, see offset calc) // to have same behaviour when scrolling down, we need to set page control to offset+1 UpdatePageControl(offset + (m_scroller.IsScrollingDown() ? 1 : 0)); m_lastRenderTime = currentTime; CGUIControl::Process(currentTime, dirtyregions); }
void CGUIPanelContainer::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) { ValidateOffset(); if (m_bInvalidated) UpdateLayout(); if (!m_layout || !m_focusedLayout) return; UpdateScrollOffset(currentTime); int offset = (int)(m_scroller.GetValue() / m_layout->Size(m_orientation)); int cacheBefore, cacheAfter; GetCacheOffsets(cacheBefore, cacheAfter); int keepStart = CorrectOffset(offset - cacheBefore, 0); int keepEnd = CorrectOffset(offset + m_itemsPerPage + 1 + cacheAfter, 0); // Free memory not used on screen if ((int)m_items.size() > m_itemsPerPage + cacheBefore + cacheAfter) FreeMemory(keepStart, keepEnd); CPoint origin = CPoint(m_posX, m_posY) + m_renderOffset; float pos = (m_orientation == VERTICAL) ? origin.y : origin.x; float end = (m_orientation == VERTICAL) ? m_posY + m_height : m_posX + m_width; pos += (offset - cacheBefore) * m_layout->Size(m_orientation) - m_scroller.GetValue(); end += cacheAfter * m_layout->Size(m_orientation); int current = (offset - cacheBefore) * m_itemsPerRow; int col = 0; while (pos < end && m_items.size()) { if (current >= (int)m_items.size()) break; if (current >= 0 && current >= keepStart && current <= keepEnd) { CGUIListItemPtr item = m_items[current]; bool focused = (current == GetOffset() * m_itemsPerRow + GetCursor()) && m_bHasFocus; if (m_orientation == VERTICAL) ProcessItem(origin.x + col * m_layout->Size(HORIZONTAL), pos, item, focused, currentTime, dirtyregions); else ProcessItem(pos, origin.y + col * m_layout->Size(VERTICAL), item, focused, currentTime, dirtyregions); } // increment our position if (col < m_itemsPerRow - 1) col++; else { pos += m_layout->Size(m_orientation); col = 0; } current++; } // when we are scrolling up, offset will become lower (integer division, see offset calc) // to have same behaviour when scrolling down, we need to set page control to offset+1 UpdatePageControl(offset + (m_scroller.IsScrollingDown() ? 1 : 0), m_itemsPerRow); CGUIControl::Process(currentTime, dirtyregions); }