C++ (Qt)void FilesAttachementManage::run(){ forever { QFileInfo fileInfo; { QMutexLocker locker(&filesReadMutex); if (readFilesQueue.isEmpty()) filesAdded.wait(&filesReadMutex); fileName = readFilesQueue.dequeue(); } fileInfo.setFile(fileName); quint64 size = fileInfo.size(); if (commonFileSize + size > MAX_ATTACHED_SIZE) { readFilesQueue.clear(); qDebug() << "continue"; continue; } QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { qDebug() << "file don't open -> " << fileName; continue; } commonFileSize += size; listOfEncodedFiles->append(file.readAll().toBase64()); qDebug() << "at end"; }}
C++ (Qt)void FilesAttachementManage::readFiles(const QStringList &fileNames){ filesReadMutex.lock(); foreach (QString file, fileNames) readFilesQueue.enqueue(file); filesReadMutex.unlock(); filesAdded.wakeOne(); }
C++ (Qt) if (readFilesQueue.isEmpty()) // <- пробой filesAdded.wait(&filesReadMutex);
C++ (Qt) if (readFilesQueue.isEmpty()) // <- proboy filesAdded.wait(&filesReadMutex);
C++ (Qt) { QMutexLocker locker(&filesReadMutex); if (readFilesQueue.isEmpty()) filesAdded.wait(&filesReadMutex); fileName = readFilesQueue.dequeue(); }