static PyObject *meth_QWriteLocker___exit__(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { PyObject * a0; PyObject * a1; PyObject * a2; QWriteLocker *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BP0P0P0", &sipSelf, sipType_QWriteLocker, &sipCpp, &a0, &a1, &a2)) { #line 99 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\sip/QtCore/qreadwritelock.sip" sipCpp->unlock(); #line 165 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\QtCore/sipQtCoreQWriteLocker.cpp" Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QWriteLocker, sipName___exit__, doc_QWriteLocker___exit__); return NULL; }
void TabProgress::unkillXtalProgress_() { if (!m_context_xtal) { emit finishedBackgroundProcessing(); return; } QWriteLocker locker (m_context_xtal->lock()); if (m_context_xtal->getStatus() != Xtal::Killed && m_context_xtal->getStatus() != Xtal::Removed ) { emit finishedBackgroundProcessing(); return; } // Setting status to Xtal::Error will restart the job if was killed if (m_context_xtal->getStatus() == Xtal::Killed) m_context_xtal->setStatus(Xtal::Error); // Set status to Optimized if xtal was previously optimized else if (m_context_xtal->getStatus() == Xtal::Removed) m_context_xtal->setStatus(Xtal::Optimized); // Clear context xtal pointer emit finishedBackgroundProcessing(); newInfoUpdate(m_context_xtal); locker.unlock(); m_context_xtal = 0; }
void AudioMixerClientData::removeAgentAvatarAudioStream() { QWriteLocker writeLocker { &_streamsLock }; auto it = _audioStreams.find(QUuid()); if (it != _audioStreams.end()) { _audioStreams.erase(it); } writeLocker.unlock(); }
void TabProgress::resetFailureCountProgress_() { if (!m_context_scene) return; QWriteLocker locker (m_context_scene->lock()); m_context_scene->resetFailCount(); // Clear context scene pointer newInfoUpdate(m_context_scene); locker.unlock(); m_context_scene = 0; }
void TabProgress::restartJobProgress_(int optStep) { QWriteLocker locker (m_context_scene->lock()); m_context_scene->setCurrentOptStep(optStep); m_context_scene->setStatus(Scene::Restart); newInfoUpdate(m_context_scene); // Clear context scene pointer locker.unlock(); m_context_scene = 0; }
void TabProgress::restartJobProgress_(int optStep) { QWriteLocker locker (m_context_xtal->lock()); m_context_xtal->setCurrentOptStep(optStep); m_context_xtal->setStatus(Xtal::Restart); newInfoUpdate(m_context_xtal); // Clear context xtal pointer emit finishedBackgroundProcessing(); locker.unlock(); m_context_xtal = 0; }
void TabProgress::resetFailureCountProgress_() { if (!m_context_xtal) { emit finishedBackgroundProcessing(); return; } QWriteLocker locker (m_context_xtal->lock()); m_context_xtal->resetFailCount(); // Clear context xtal pointer emit finishedBackgroundProcessing(); newInfoUpdate(m_context_xtal); locker.unlock(); m_context_xtal = 0; }
void TabProgress::unkillSceneProgress_() { if (!m_context_scene) return; QWriteLocker locker (m_context_scene->lock()); if (m_context_scene->getStatus() != Scene::Killed && m_context_scene->getStatus() != Scene::Removed ) return; // Setting status to Scene::Error will restart the job if was killed if (m_context_scene->getStatus() == Scene::Killed) m_context_scene->setStatus(Scene::Error); // Set status to Optimized if scene was previously optimized if (m_context_scene->getStatus() == Scene::Removed) m_context_scene->setStatus(Scene::Optimized); // Clear context scene pointer newInfoUpdate(m_context_scene); locker.unlock(); m_context_scene = 0; }
static PyObject *meth_QWriteLocker_unlock(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { QWriteLocker *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QWriteLocker, &sipCpp)) { sipCpp->unlock(); Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QWriteLocker, sipName_unlock, doc_QWriteLocker_unlock); return NULL; }
QStringList SgeQueueInterface::getQueueList() const { // recast queue mutex as mutable for safe access: QReadWriteLock &queueMutex = const_cast<QReadWriteLock&> (m_queueMutex); queueMutex.lockForRead(); // Limit queries to once per second if (m_queueTimeStamp.isValid() && // QDateTime::msecsTo is not implemented until Qt 4.7 #if QT_VERSION >= 0x040700 m_queueTimeStamp.msecsTo(QDateTime::currentDateTime()) <= 1000*m_interval #else // Check if day is the same. If not, refresh. Otherwise check // msecsTo current time (m_queueTimeStamp.date() == QDate::currentDate() && m_queueTimeStamp.time().msecsTo(QTime::currentTime()) <= 1000*m_interval) #endif // QT_VERSION >= 4.7 ) { // If the cache is valid, return it QStringList ret (m_queueData); queueMutex.unlock(); return ret; } // Otherwise, store a copy of the current timestamp and switch // queuemutex to writelock QDateTime oldTimeStamp (m_queueTimeStamp); queueMutex.unlock(); // Relock mutex QWriteLocker queueLocker (&queueMutex); // Non-fatal assert: Check current timestamp against the // oldTimeStamp from earlier. If they don't match, another thread // has already updated the queueData, so tail-recurse this // function and try again. if (m_queueTimeStamp.time().msecsTo(oldTimeStamp.time()) != 0) { queueLocker.unlock(); return this->getQueueList(); } // Queue will be updated -- cast queue cache and timestamp as // mutable QStringList &queueData = const_cast<QStringList&> (m_queueData); QDateTime &queueTimeStamp = const_cast<QDateTime&> (m_queueTimeStamp); // Get SSH connection SSHConnection *ssh = m_opt->ssh()->getFreeConnection(); if (ssh == NULL) { m_opt->warning(tr("Cannot connect to ssh server")); queueTimeStamp = QDateTime::currentDateTime(); queueData.clear(); queueData << "CommError"; QStringList ret (m_queueData); return ret; } QString command = m_qstat + " | grep " + m_opt->username; // Execute QString stdout_str; QString stderr_str; int ec; // Valid exit codes for grep: (0) matches found, execution successful // (1) no matches found, execution successful // (2) execution unsuccessful if (!ssh->execute(command, stdout_str, stderr_str, ec) || (ec != 0 && ec != 1 ) ) { m_opt->ssh()->unlockConnection(ssh); m_opt->warning(tr("Error executing %1: (%2) %3\n\t" "Using cached queue data.") .arg(command) .arg(QString::number(ec)) .arg(stderr_str)); queueTimeStamp = QDateTime::currentDateTime(); QStringList ret (m_queueData); return ret; } m_opt->ssh()->unlockConnection(ssh); queueData = stdout_str.split("\n", QString::SkipEmptyParts); QStringList ret (m_queueData); queueTimeStamp = QDateTime::currentDateTime(); return ret; }
QueueInterface::QueueStatus SgeQueueInterface::getStatus(Structure *s) const { // lock structure QWriteLocker locker (s->lock()); QStringList queueData = getQueueList(); unsigned int jobID = static_cast<unsigned int>(s->getJobID()); // If the queueData cannot be fetched, queueData contains a single // string, "CommError" if (queueData.size() == 1 && queueData[0].compare("CommError") == 0) { return QueueInterface::CommunicationError; } // If jobID = 0 and structure is not in "Submitted" state, return an error. if (!jobID && s->getStatus() != Structure::Submitted) { return QueueInterface::Error; } // Determine status if structure is in the queue. queueData // entries are of the following format: // // job-ID prior name user state submit/start at queue function // 231 0 hydra craig r 07/13/96 durin.q MASTER // 20:27:15 // // (Note that the whitespace has been condensed in the above) QString status; QStringList list; for (int i = 0; i < queueData.size(); i++) { list = queueData.at(i).split(QRegExp("\\s+"), QString::SkipEmptyParts); if (list[0].toUInt() == jobID) { status = list[4]; continue; } } // If structure is submitted, check if it is in the queue. If not, // check if the completion file has been written. // // If the completion file exists, then the job finished before the // queue checks could see it, and the function will continue on to // the status checks below. // // If the structure in Submitted state if (s->getStatus() == Structure::Submitted) { // and the jobID isn't in the queue if (status.isEmpty()) { // check if the output file is absent bool exists; if (!m_opt->optimizer()->checkIfOutputFileExists(s, &exists)) { return QueueInterface::CommunicationError; } if (!exists) { // The job is still pending return QueueInterface::Pending; } else { // The job has completed. return QueueInterface::Started; } } else { // The job is in the queue return QueueInterface::Started; } } if (status.contains('r')) { return QueueInterface::Running; } else if (status.contains(QRegExp("q|w|s"))) { return QueueInterface::Queued; } else { // Entry is missing from queue. Were the output files written? locker.unlock(); bool outputFileExists; if (!m_opt->optimizer()->checkIfOutputFileExists(s, &outputFileExists) ) { return QueueInterface::CommunicationError; } locker.relock(); if (outputFileExists) { // Did the job finish successfully? bool success; if (!m_opt->optimizer()->checkForSuccessfulOutput(s, &success)) { return QueueInterface::CommunicationError; } if (success) { return QueueInterface::Success; } else { return QueueInterface::Error; } } } // Not in queue and no output? return QueueInterface::Unknown; }
int AudioMixerClientData::parseData(ReceivedMessage& message) { PacketType packetType = message.getType(); if (packetType == PacketType::AudioStreamStats) { // skip over header, appendFlag, and num stats packed message.seek(sizeof(quint8) + sizeof(quint16)); // read the downstream audio stream stats message.readPrimitive(&_downstreamAudioStreamStats); return message.getPosition(); } else { SharedStreamPointer matchingStream; bool isMicStream = false; if (packetType == PacketType::MicrophoneAudioWithEcho || packetType == PacketType::ReplicatedMicrophoneAudioWithEcho || packetType == PacketType::MicrophoneAudioNoEcho || packetType == PacketType::ReplicatedMicrophoneAudioNoEcho || packetType == PacketType::SilentAudioFrame || packetType == PacketType::ReplicatedSilentAudioFrame) { QWriteLocker writeLocker { &_streamsLock }; auto micStreamIt = _audioStreams.find(QUuid()); if (micStreamIt == _audioStreams.end()) { // we don't have a mic stream yet, so add it // hop past the sequence number that leads the packet message.seek(sizeof(quint16)); // pull the codec string from the packet auto codecString = message.readString(); // determine if the stream is stereo or not bool isStereo; if (packetType == PacketType::SilentAudioFrame || packetType == PacketType::ReplicatedSilentAudioFrame) { quint16 numSilentSamples; message.readPrimitive(&numSilentSamples); isStereo = numSilentSamples == AudioConstants::NETWORK_FRAME_SAMPLES_STEREO; } else { quint8 channelFlag; message.readPrimitive(&channelFlag); isStereo = channelFlag == 1; } auto avatarAudioStream = new AvatarAudioStream(isStereo, AudioMixer::getStaticJitterFrames()); avatarAudioStream->setupCodec(_codec, _selectedCodecName, isStereo ? AudioConstants::STEREO : AudioConstants::MONO); qCDebug(audio) << "creating new AvatarAudioStream... codec:" << _selectedCodecName << "isStereo:" << isStereo; connect(avatarAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioMixerClientData::handleMismatchAudioFormat); auto emplaced = _audioStreams.emplace( QUuid(), std::unique_ptr<PositionalAudioStream> { avatarAudioStream } ); micStreamIt = emplaced.first; } matchingStream = micStreamIt->second; writeLocker.unlock(); isMicStream = true; } else if (packetType == PacketType::InjectAudio || packetType == PacketType::ReplicatedInjectAudio) { // this is injected audio // grab the stream identifier for this injected audio message.seek(sizeof(quint16)); QUuid streamIdentifier = QUuid::fromRfc4122(message.readWithoutCopy(NUM_BYTES_RFC4122_UUID)); bool isStereo; message.readPrimitive(&isStereo); QWriteLocker writeLock { &_streamsLock }; auto streamIt = _audioStreams.find(streamIdentifier); if (streamIt == _audioStreams.end()) { // we don't have this injected stream yet, so add it auto injectorStream = new InjectedAudioStream(streamIdentifier, isStereo, AudioMixer::getStaticJitterFrames()); #if INJECTORS_SUPPORT_CODECS injectorStream->setupCodec(_codec, _selectedCodecName, isStereo ? AudioConstants::STEREO : AudioConstants::MONO); qCDebug(audio) << "creating new injectorStream... codec:" << _selectedCodecName << "isStereo:" << isStereo; #endif auto emplaced = _audioStreams.emplace( streamIdentifier, std::unique_ptr<InjectedAudioStream> { injectorStream } ); streamIt = emplaced.first; } matchingStream = streamIt->second; writeLock.unlock(); } // seek to the beginning of the packet so that the next reader is in the right spot message.seek(0); // check the overflow count before we parse data auto overflowBefore = matchingStream->getOverflowCount(); auto parseResult = matchingStream->parseData(message); if (matchingStream->getOverflowCount() > overflowBefore) { qCDebug(audio) << "Just overflowed on stream from" << message.getSourceID() << "at" << message.getSenderSockAddr(); qCDebug(audio) << "This stream is for" << (isMicStream ? "microphone audio" : "injected audio"); } return parseResult; } return 0; }
int AudioMixerClientData::parseData(ReceivedMessage& message) { PacketType packetType = message.getType(); if (packetType == PacketType::AudioStreamStats) { // skip over header, appendFlag, and num stats packed message.seek(sizeof(quint8) + sizeof(quint16)); // read the downstream audio stream stats message.readPrimitive(&_downstreamAudioStreamStats); return message.getPosition(); } else { SharedStreamPointer matchingStream; bool isMicStream = false; if (packetType == PacketType::MicrophoneAudioWithEcho || packetType == PacketType::MicrophoneAudioNoEcho || packetType == PacketType::SilentAudioFrame) { QWriteLocker writeLocker { &_streamsLock }; auto micStreamIt = _audioStreams.find(QUuid()); if (micStreamIt == _audioStreams.end()) { // we don't have a mic stream yet, so add it // read the channel flag to see if our stream is stereo or not message.seek(sizeof(quint16)); quint8 channelFlag; message.readPrimitive(&channelFlag); bool isStereo = channelFlag == 1; auto emplaced = _audioStreams.emplace( QUuid(), std::unique_ptr<PositionalAudioStream> { new AvatarAudioStream(isStereo, AudioMixer::getStreamSettings()) } ); micStreamIt = emplaced.first; } matchingStream = micStreamIt->second; writeLocker.unlock(); isMicStream = true; } else if (packetType == PacketType::InjectAudio) { // this is injected audio // grab the stream identifier for this injected audio message.seek(sizeof(quint16)); QUuid streamIdentifier = QUuid::fromRfc4122(message.readWithoutCopy(NUM_BYTES_RFC4122_UUID)); bool isStereo; message.readPrimitive(&isStereo); QWriteLocker writeLock { &_streamsLock }; auto streamIt = _audioStreams.find(streamIdentifier); if (streamIt == _audioStreams.end()) { // we don't have this injected stream yet, so add it auto emplaced = _audioStreams.emplace( streamIdentifier, std::unique_ptr<InjectedAudioStream> { new InjectedAudioStream(streamIdentifier, isStereo, AudioMixer::getStreamSettings()) } ); streamIt = emplaced.first; } matchingStream = streamIt->second; writeLock.unlock(); } // seek to the beginning of the packet so that the next reader is in the right spot message.seek(0); // check the overflow count before we parse data auto overflowBefore = matchingStream->getOverflowCount(); auto parseResult = matchingStream->parseData(message); if (matchingStream->getOverflowCount() > overflowBefore) { qDebug() << "Just overflowed on stream from" << message.getSourceID() << "at" << message.getSenderSockAddr(); qDebug() << "This stream is for" << (isMicStream ? "microphone audio" : "injected audio"); } return parseResult; } return 0; }