本文整理汇总了C++中QQueue::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QQueue::isEmpty方法的具体用法?C++ QQueue::isEmpty怎么用?C++ QQueue::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQueue
的用法示例。
在下文中一共展示了QQueue::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void LoggerThread::run(void)
{
RunProlog();
logThreadFinished = false;
QMutexLocker qLock(&logQueueMutex);
while (!aborted || !logQueue.isEmpty())
{
if (logQueue.isEmpty())
{
m_waitEmpty->wakeAll();
m_waitNotEmpty->wait(qLock.mutex(), 100);
continue;
}
LoggingItem *item = logQueue.dequeue();
qLock.unlock();
handleItem(item);
deleteItem(item);
qLock.relock();
}
logThreadFinished = true;
qLock.unlock();
RunEpilog();
}
示例2: addFramesToDeinterlace
int DeintFilter::addFramesToDeinterlace(QQueue< FrameBuffer > &framesQueue, bool checkSize)
{
while (!framesQueue.isEmpty())
{
VideoFrame *videoFrame = VideoFrame::fromData(framesQueue.first().data);
if (((deintFlags & AutoDeinterlace) && !videoFrame->interlaced) || (checkSize && !videoFrame->data_size))
break;
internalQueue.enqueue(framesQueue.dequeue());
}
return framesQueue.isEmpty();
}
示例3: flush
/// \brief Wait for the queue to be flushed (up to a timeout)
/// \param timeoutMS The number of ms to wait for the queue to flush
/// \return true if the queue is empty, false otherwise
bool LoggerThread::flush(int timeoutMS)
{
QTime t;
t.start();
while (!m_aborted && !logQueue.isEmpty() && t.elapsed() < timeoutMS)
{
m_waitNotEmpty->wakeAll();
int left = timeoutMS - t.elapsed();
if (left > 0)
m_waitEmpty->wait(&logQueueMutex, left);
}
return logQueue.isEmpty();
}
示例4: run
//! 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);
}
示例5: runtimePlaylist
void CmdPlaylist::runtimePlaylist()
{
// filter
MediaLibraryModel::MediaType type = this->mediaTypeFilter(this->m_args, this->cmdAudio, this->cmdVideo, this->cmdModule);
// search for media
QList<MediaLibraryModel::Media*> search_results = this->ptr_media_model->findMultiple(this->m_args, type);
// empty check
if (search_results.isEmpty())
{
this->print_nothingfound();
return;
}
// build runtime playlist
QQueue<MediaLibraryModel::Media*> plist;
for (MediaLibraryModel::Media *media : search_results)
plist.enqueue(media);
search_results.clear();
// start the playlist
if (type == MediaLibraryModel::None)
{
KBHIT_NOT_INFINITE(plist.isEmpty())
MediaPlayerController::i()->play(plist.dequeue(), MediaLibraryModel::Audio);
KBHIT_NOT_INFINITE_END
}
示例6: topologicSorting
void BalanceGraph::topologicSorting()
{
QQueue<Segment*> queue;
QList<Segment*> topologicSorted;
int topologicIndex = 0;
for(Segment* segment : segments) {
if(segment->predecessors.isEmpty()) {
segment->topologicNumber = topologicIndex;
queue.enqueue(segment);
topologicSorted.append(segment);
topologicIndex++;
}
}
while(!queue.isEmpty()) {
Segment* segment = queue.dequeue();
for(Segment* succ : segment->successors) {
succ->predecessors.removeOne(segment);
if(succ->predecessors.isEmpty()) {
succ->topologicNumber = topologicIndex;
queue.enqueue(succ);
topologicSorted.append(succ);
topologicIndex++;
}
}
}
segments = topologicSorted;
}
示例7: collectionListResult
void RecursiveMover::collectionListResult( KJob *job )
{
Q_ASSERT( m_pendingCollections.isEmpty() );
--m_runningJobs;
if ( job->error() )
return; // error handling is in the base class
// build a parent -> children map for the following topological sorting
// while we are iterating anyway, also fill m_collections here
CollectionFetchJob *fetchJob = qobject_cast<CollectionFetchJob*>( job );
QHash<Collection::Id, Collection::List> colTree;
foreach ( const Collection &col, fetchJob->collections() ) {
colTree[col.parentCollection().id()] << col;
m_collections.insert( col.id(), col );
}
// topological sort; BFS traversal of the tree
m_pendingCollections.push_back( m_movedCollection );
QQueue<Collection> toBeProcessed;
toBeProcessed.enqueue( m_movedCollection );
while ( !toBeProcessed.isEmpty() ) {
const Collection col = toBeProcessed.dequeue();
const Collection::List children = colTree.value( col.id() );
if ( children.isEmpty() )
continue;
m_pendingCollections.append( children );
foreach ( const Collection &child, children )
toBeProcessed.enqueue( child );
}
replayNextCollection();
}
示例8: testQueue
void testQueue()
{
QQueue<QByteArray> values;
values << "value1";
values << "value2";
MessageQueue queue(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue");
for (const QByteArray &value : values) {
queue.enqueue(value.data(), value.size());
}
while (!queue.isEmpty()) {
const auto expected = values.dequeue();
bool gotValue = false;
bool gotError = false;
queue.dequeue([&](void *ptr, int size, std::function<void(bool success)> callback) {
if (QByteArray(static_cast<char*>(ptr), size) == expected) {
gotValue = true;
}
callback(true);
},
[&](const MessageQueue::Error &error) {
gotError = true;
});
QVERIFY(gotValue);
QVERIFY(!gotError);
}
QVERIFY(values.isEmpty());
}
示例9: lookupBases
void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
{
using Data = QPair<ClassOrNamespace*, CppClass*>;
if (ClassOrNamespace *clazz = context.lookupType(declaration)) {
QSet<ClassOrNamespace *> visited;
QQueue<Data> q;
q.enqueue(qMakePair(clazz, this));
while (!q.isEmpty()) {
Data current = q.dequeue();
clazz = current.first;
visited.insert(clazz);
const QList<ClassOrNamespace *> &bases = clazz->usings();
foreach (ClassOrNamespace *baseClass, bases) {
const QList<Symbol *> &symbols = baseClass->symbols();
foreach (Symbol *symbol, symbols) {
if (symbol->isClass() && (
clazz = context.lookupType(symbol)) &&
!visited.contains(clazz)) {
CppClass baseCppClass(symbol);
CppClass *cppClass = current.second;
cppClass->bases.append(baseCppClass);
q.enqueue(qMakePair(clazz, &cppClass->bases.last()));
}
}
}
}
}
示例10: operator
bool TreeEnumerate::operator ()()
{
QQueue<letter_node *> queue;
queue.clear();
filled_details=false;
queue.enqueue((letter_node*)Tree->getFirstNode());
bool stop=false;
while ((!queue.isEmpty()) && !stop) {
node * current_node=NULL;
current_node=queue.dequeue();
addLetterToQueue(queue,current_node);
QList<result_node *>* current_result_children=current_node->getResultChildren();
int num_children=current_result_children->count();
for (int j=0;j<num_children;j++) {
result_node *current_child=current_result_children->at(j);
reached_node=current_child;
resulting_category_idOFCurrentMatch=((result_node *)current_child)->get_resulting_category_id();
bool isAccept=((result_node *)current_child)->is_accept_state();
if ( isAccept && shouldcall_onmatch_ex() && !(on_match_helper())) {
stop=true;
break;
} else {
addLetterToQueue(queue,current_child);
}
}
}
return (!stop);
}
示例11: moveColumnsRight
void TreeWidgetEditor::moveColumnsRight(int fromColumn, int toColumn)
{
if (fromColumn >= toColumn)
return;
QTreeWidgetItem *headerItem = ui.treeWidget->headerItem();
QString text = headerItem->text(fromColumn);
QIcon icon = headerItem->icon(fromColumn);
for (int i = fromColumn; i < toColumn; i++) {
headerItem->setText(i, headerItem->text(i + 1));
headerItem->setIcon(i, headerItem->icon(i + 1));
}
headerItem->setText(toColumn, text);
headerItem->setIcon(toColumn, icon);
QQueue<QTreeWidgetItem *> pendingQueue;
for (int i = 0; i < ui.treeWidget->topLevelItemCount(); i++)
pendingQueue.enqueue(ui.treeWidget->topLevelItem(i));
while (!pendingQueue.isEmpty()) {
QTreeWidgetItem *item = pendingQueue.dequeue();
for (int i = 0; i < item->childCount(); i++)
pendingQueue.enqueue(item->child(i));
QString text = item->text(fromColumn);
QIcon icon = item->icon(fromColumn);
for (int i = fromColumn; i < toColumn; i++) {
item->setText(i, item->text(i + 1));
item->setIcon(i, item->icon(i + 1));
}
item->setText(toColumn, text);
item->setIcon(toColumn, icon);
}
}
示例12: createPaths
void QtResourceViewPrivate::createPaths()
{
if (!m_resourceModel)
return;
const QString root(QLatin1Char(':'));
QMap<QString, QString> contents = m_resourceModel->contents();
QMapIterator<QString, QString> itContents(contents);
while (itContents.hasNext()) {
const QString filePath = itContents.next().key();
const QFileInfo fi(filePath);
QString dirPath = fi.absolutePath();
m_pathToContents[dirPath].append(fi.fileName());
while (!m_pathToParentPath.contains(dirPath) && dirPath != root) { // create all parent paths
const QFileInfo fd(dirPath);
const QString parentDirPath = fd.absolutePath();
m_pathToParentPath[dirPath] = parentDirPath;
m_pathToSubPaths[parentDirPath].append(dirPath);
dirPath = parentDirPath;
}
}
QQueue<QPair<QString, QTreeWidgetItem *> > pathToParentItemQueue;
pathToParentItemQueue.enqueue(qMakePair(root, static_cast<QTreeWidgetItem *>(0)));
while (!pathToParentItemQueue.isEmpty()) {
QPair<QString, QTreeWidgetItem *> pathToParentItem = pathToParentItemQueue.dequeue();
const QString path = pathToParentItem.first;
QTreeWidgetItem *item = createPath(path, pathToParentItem.second);
QStringList subPaths = m_pathToSubPaths.value(path);
QStringListIterator itSubPaths(subPaths);
while (itSubPaths.hasNext())
pathToParentItemQueue.enqueue(qMakePair(itSubPaths.next(), item));
}
}
示例13: processBytes
void Telnet::processBytes(QByteArray bytes)
{
QQueue<uchar> buffer;
foreach (uchar c, bytes)
{
switch (_state)
{
case TOP_LEVEL:
handleStateTopLevel(c, &buffer);
break;
case SEENCR:
handleStateSeenCr(c, &buffer);
break;
case SEENIAC:
handleStateSeenIac(c);
break;
case SEENWILL:
handleStateSeenWill(c);
break;
case SEENWONT:
sendCommand(DONT, c);
_state = TOP_LEVEL;
break;
case SEENDO:
handleStateSeenDo(c);
break;
case SEENDONT:
sendCommand(WONT, c);
_state = TOP_LEVEL;
break;
case SEENSB:
_sbOption = c;
_sbBuffer->clear();
_state = SUBNEGOT;
break;
case SUBNEGOT:
if (c == IAC)
_state = SUBNEG_IAC;
else
_sbBuffer->append(c);
break;
case SUBNEG_IAC:
handleStateSubNegIac(c);
break;
default:
break;
}
}
int chunk_sz = 256;
while (!buffer.isEmpty())
{
QByteArray data;
int length = buffer.size() < chunk_sz ? buffer.size() : chunk_sz;
for (int i = 0; i < length; i++)
data.append(buffer.dequeue());
emit processedBytes(data);
}
}
示例14: run
void RefInterface::run()
{
while(!stopped)
{
//qDebug("Reference thread run");
mutex.lock();
range();
emit getIMUData();
if(!msg.isEmpty())
{
msg.clear();
}
switch(count)
{
case 1: solver->find_intersection_points_nlls3d(x0 ,y0, z0, r0, x1, y1, z1, r1, x2
, y2, z2, r2, 0.0, 0.0, 0.5, px, py, pz );
count = count + 1;
break;
case 2: solver->find_intersection_points_nlls3d(x1 ,y1, z1, r1, x2, y2, z2, r2, x3
, y3, z3, r3, 0.0, 0.0, 0.5, px, py, pz );
count = count + 1;
break;
case 3: solver->find_intersection_points_nlls3d(x2 ,y2, z2, r2, x3, y3, z3, r3, x0
, y0, z0, r0, 0.0, 0.0, 0.5, px, py, pz );
count = count + 1;
break;
case 4: solver->find_intersection_points_nlls3d(x3 ,y3, z3, r3, x3, y0, z0, r0, x1
, y1, z1, r1, 0.0, 0.0, 0.5, px, py, pz );
count = 1;
break;
default:
break;
}
//Here I set the buffer struct to the position returned from solver
oldx = px;
oldy = py;
oldz = pz;
buffer.x = px;
buffer.y = py;
buffer.z = pz;
//append the buffer to the queue
msg.append(buffer);
//unlock the mutex so the consumer can have access to buffer
mutex.unlock();
//set stopped to true, so consumer has a turn
stopped = false;
}
}
示例15: getFramebuffer
gpu::FramebufferPointer FramebufferCache::getFramebuffer() {
if (_cachedFramebuffers.isEmpty()) {
_cachedFramebuffers.push_back(gpu::FramebufferPointer(gpu::Framebuffer::create(gpu::Element::COLOR_RGBA_32, _frameBufferSize.width(), _frameBufferSize.height())));
}
gpu::FramebufferPointer result = _cachedFramebuffers.front();
_cachedFramebuffers.pop_front();
return result;
}