当前位置: 首页>>代码示例>>C++>>正文


C++ QMutex::unlock方法代码示例

本文整理汇总了C++中QMutex::unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ QMutex::unlock方法的具体用法?C++ QMutex::unlock怎么用?C++ QMutex::unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMutex的用法示例。


在下文中一共展示了QMutex::unlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sendLoadSceneRPC

void sendLoadSceneRPC(Player* player, QString sceneName) // Loads a scene and send to the default spawn
{
    win.logMessage(QString("UDP: Loading scene \"") + sceneName + "\" on "+QString().setNum(player->pony.netviewId));
    Vortex vortex = findVortex(sceneName, 0);
    if (vortex.destName.isEmpty())
    {
        win.logMessage("UDP: Scene not in vortex DB. Aborting scene load.");
        return;
    }

    Scene* scene = findScene(sceneName);
    Scene* oldScene = findScene(player->pony.sceneName);
    if (scene->name.isEmpty() || oldScene->name.isEmpty())
    {
        win.logMessage("UDP: Can't find the scene, aborting");
        return;
    }

    // Update scene players
    //win.logMessage("sendLoadSceneRPC: locking");
    levelLoadMutex.lock();
    player->inGame=1;
    player->pony.pos = vortex.destPos;
    player->pony.sceneName = sceneName;
    player->lastValidReceivedAnimation.clear(); // Changing scenes resets animations
    Player::removePlayer(oldScene->players, player->IP, player->port);
    if (oldScene->name != sceneName)
    {
        // Send remove RPC to the other players of the old scene
        for (int i=0; i<oldScene->players.size(); i++)
            sendNetviewRemove(oldScene->players[i], player->pony.netviewId);

        // Send instantiate to the players of the new scene
        for (int i=0; i<scene->players.size(); i++)
            if (scene->players[i]->inGame>=2)
                sendNetviewInstantiate(player, scene->players[i]);
    }
    scene->players << player;

    QByteArray data(1,5);
    data += stringToData(sceneName);
    sendMessage(player,MsgUserReliableOrdered6,data); // Sends a 48
    //win.logMessage("sendLoadSceneRPC: unlocking");
    levelLoadMutex.unlock();
}
开发者ID:ChipChoq,项目名称:LoE-PrivateServer,代码行数:45,代码来源:messages.cpp

示例2: internalGet

void
IdThreadWorker::getArtistId( const artist_ptr& artist, bool autoCreate )
{
    QueueItem* item = internalGet( artist, album_ptr(), trackdata_ptr(), autoCreate, ArtistType );
    artist->setIdFuture( item->promise.future() );

#if ID_THREAD_DEBUG
    tDebug() << "QUEUEING ARTIST:" << artist->name();
#endif

    s_mutex.lock();
    s_workQueue.enqueue( item );
    s_mutex.unlock();
    s_waitCond.wakeOne();
#if ID_THREAD_DEBUG
    tDebug() << "DONE WOKE UP THREAD:" << artist->name();
#endif
}
开发者ID:ehaas,项目名称:tomahawk,代码行数:18,代码来源:IdThreadWorker.cpp

示例3:

Data::Data(int typeId,
           equals_fn equals, lessThan_fn lessThan,
           castTo_fn castTo, convertTo_fn convertTo, convertFrom_fn convertFrom,
           canCastTo_fn canCastTo, canConvertTo_fn canConvertTo, canConvertFrom_fn canConvertFrom ) :
    typeId_( lh_lock_and_filter( typeId ) ),
    equals_( equals ),
    lessThan_( lessThan ),
    castTo_( castTo ),
    convertTo_( convertTo ),
    convertFrom_( convertFrom ),
    canCastTo_( canCastTo ),
    canConvertTo_( canConvertTo ),
    canConvertFrom_( canConvertFrom ),
    next_( typeId_ ? lh_first_info_ : 0 )
{
    if( typeId_ ) lh_first_info_ = this;
    lh_type_data_mutex_.unlock();
}
开发者ID:AllainFortier,项目名称:lcdhost,代码行数:18,代码来源:Type_Data.cpp

示例4: project

    void project(const Template &src, Template &dst) const
    {
        dst = src;

        if (Globals->parallelism) {
            qWarning("Edit::project() only works in single threaded mode.");
            return;
        }

        currentTemplateLock.lock();
        currentTemplate = src;
        OpenCVUtils::showImage(src, "Edit", false);
        setMouseCallback("Edit", mouseCallback, (void*)this);
        mouseEvent(0, 0, 0, 0);
        waitKey(-1);
        dst = currentTemplate;
        currentTemplateLock.unlock();
    }
开发者ID:emillundh,项目名称:openbr,代码行数:18,代码来源:draw.cpp

示例5: onReset

void Person::onReset() {
    QMutex mutex;
    mutex.lock();
    this->stop = true;
    mutex.unlock();

    this->inCS = false;
    this->isWaiting = false;
    this->requests = new QVector<int>();
    this->awks = new QVector<int>();

    QPoint moveBy;
    moveBy.setX(this->initialPosition.x() - this->position.x());
    moveBy.setY(this->initialPosition.y() - this->position.y());
    emit this->ChangePosition(this->id, moveBy);

    this->position += moveBy;
}
开发者ID:pts211,项目名称:CS384,代码行数:18,代码来源:person.cpp

示例6: run

void processsimthread::run()
{
    QMutex mutex;
    int counter = 0;
    this->Stop = false;
    while(!this->Stop)
    {
       mutex.lock();
       counter++;
       if (counter == 100) {
           counter = 0;
       }
       emit processValueChanged(counter);
       mutex.unlock();
       QThread::msleep(100);

    }
}
开发者ID:carriercomm,项目名称:AdAndCrapBlock,代码行数:18,代码来源:processsimthread.cpp

示例7: post

void QWaitConditionPrivate::post(QWaitConditionEvent *wce, bool ret)
{
    mtx.lock();

    // remove 'wce' from the queue
    queue.removeAll(wce);
    ResetEvent(wce->event);
    freeQueue.append(wce);

    // wakeups delivered after the timeout should be forwarded to the next waiter
    if (!ret && wce->wokenUp && !queue.isEmpty()) {
        QWaitConditionEvent *other = queue.first();
        SetEvent(other->event);
        other->wokenUp = true;
    }

    mtx.unlock();
}
开发者ID:66eli77,项目名称:RadChip,代码行数:18,代码来源:qwaitcondition_win.cpp

示例8: customMessageHandler

void customMessageHandler(QtMsgType type, const char *msg)
{
    static QMutex mutex;
    mutex.lock();

    QString text;
    switch(type)
    {
    case QtDebugMsg:
        text = QString("Debug:");
        break;

    case QtWarningMsg:
        text = QString("Warning:");
        break;

    case QtCriticalMsg:
        text = QString("Critical:");
        break;

    case QtFatalMsg:
        text = QString("Fatal:");
    }

    QString current_date_time = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
    QString current_date = QString("(%1)").arg(current_date_time);
    QString message = QString("%1 %2 %3").arg(text).arg(current_date).arg(msg);

    QFile file("log.txt");
    if (file.size() > 104857600)//size large than 100M split
    {
        QString filedate = QDateTime::currentDateTime().toString("yyyy-MM-dd--hh-mm-ss");
        file.rename(QString("log_%1.txt").arg(filedate));
        file.setFileName("log.txt");
    }
    file.open(QIODevice::WriteOnly | QIODevice::Append);
    QTextStream text_stream(&file);
    text_stream.setCodec(QTextCodec::codecForName("System"));
    text_stream << message << "\r\n";
    file.flush();
    file.close();

    mutex.unlock();
}
开发者ID:ypvk,项目名称:WebSearch,代码行数:44,代码来源:main.cpp

示例9: sendLoadSceneRPC

void sendLoadSceneRPC(Player* player, QString sceneName, UVector pos) // Loads a scene and send to the given pos
{
    win.logMessage(QString(QString("UDP: Loading scene \"")+sceneName
                           +"\" to "+QString().setNum(player->pony.netviewId)
                           +" at "+QString().setNum(pos.x)+" "
                           +QString().setNum(pos.y)+" "
                           +QString().setNum(pos.z)));

    Scene* scene = findScene(sceneName);
    Scene* oldScene = findScene(player->pony.sceneName);
    if (scene->name.isEmpty() || oldScene->name.isEmpty())
    {
        win.logMessage("UDP: Can't find the scene, aborting");
        return;
    }

    // Update scene players
    //win.logMessage("sendLoadSceneRPC pos: locking");
    levelLoadMutex.lock();
    player->inGame=1;
    player->pony.pos = pos;
    player->pony.sceneName = sceneName.toLower();
    player->lastValidReceivedAnimation.clear(); // Changing scenes resets animations
    Player::removePlayer(oldScene->players, player->IP, player->port);
    if (oldScene->name.toLower() != sceneName.toLower())
    {
        // Send remove RPC to the other players of the old scene
        for (int i=0; i<oldScene->players.size(); i++)
            sendNetviewRemove(oldScene->players[i], player->pony.netviewId);

        // Send instantiate to the players of the new scene
        for (int i=0; i<scene->players.size(); i++)
            if (scene->players[i]->inGame>=2)
                sendNetviewInstantiate(&player->pony, scene->players[i]);
    }
    scene->players << player;

    QByteArray data(1,5);
    data += stringToData(sceneName.toLower());
    sendMessage(player,MsgUserReliableOrdered6,data); // Sends a 48
    //win.logMessage("sendLoadSceneRPC pos: unlocking");
    levelLoadMutex.unlock();
}
开发者ID:r457r2,项目名称:LoE-PrivateServer,代码行数:43,代码来源:messages.cpp

示例10: GetDataFromQueuen

 bool GetDataFromQueuen(pComdata pData)
 {
     bool m_bbSuccess=false;
     if(pData == NULL)
     return m_bbSuccess;
     memset(pData,0,sizeof(Comdata));
     DataMutex.lock();
     if(m_outCount!=m_intoCount)
    {
     memcpy(pData,&mtQueuen[m_outCount++],sizeof(Comdata));
     if(m_outCount>=QueuenSize)
     m_outCount=0;
     m_bbSuccess=true;
     }


     DataMutex.unlock();
     return  m_bbSuccess;
 }
开发者ID:vcheung,项目名称:CranePro,代码行数:19,代码来源:dowithserdata.cpp

示例11: run

void TextProducer::run()
{
    static int index = 0;
    static QMutex indexMutex;

    for( int i=0; i<m_text.length(); ++i )
    {
        freeSpace.acquire();
        indexMutex.lock();
        buffer[ index++ % bufferSize ] = m_text[i];
        indexMutex.unlock();

        if( i == m_text.length()-1 )
            //atEnd = true;
            atEnd.acquire();

        availableData.release();
    }
}
开发者ID:embicoin,项目名称:Foundations.of.Qt.Development,代码行数:19,代码来源:textproducerconsumer.cpp

示例12: run

    void run()
    {
        test_mutex.lock();
        test_mutex.lock();
        test_mutex.lock();
        test_mutex.lock();

        mutex.lock();
        for (int i = 0; i < iterations; ++i) {
            cond.wakeOne();
            cond.wait(&mutex);
        }
        mutex.unlock();

        test_mutex.unlock();
        test_mutex.unlock();
        test_mutex.unlock();
        test_mutex.unlock();
    }
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:19,代码来源:tst_qmutex.cpp

示例13: event

bool QSpotifySearch::event(QEvent *e)
{
    if (e->type() == QEvent::User) {
        auto ev = static_cast<SearchResultEvent*>(e);
        if (ev) {
            if (auto search = ev->getSearch()) {
                g_mutex.lock();
                bool is_current = (m_sp_search == search);
                g_mutex.unlock();
                if (sp_search_error(search) == SP_ERROR_OK && is_current) {
                    if(ev->getPtr()) {
                        switch(ev->getPtr()->mType) {
                        case Albums:
                            populateAlbums(search);
                            break;
                        case Artists:
                            populateArtists(search);
                            break;
                        case Playlists:
                            populatePlaylists(search);
                            break;
                        case Tracks:
                            populateTracks(search);
                            break;
                        default:
                            populateResults(search);
                            break;
                        }
                    } else
                        populateResults(search);
                }
                clearSearch(search);
            }
        }
        setBusy(false);

        emit resultsChanged();

        e->accept();
        return true;
    }
    return QObject::event(e);
}
开发者ID:safri-framework,项目名称:safri-player,代码行数:43,代码来源:qspotifysearch.cpp

示例14: getPlayerMessage

MsvClientMessage* AuctionAction::getPlayerMessage(AuctionPlayerModel* resultPlayer) { // returns null if player didnt send anything
	qDebug() << "AuctionAction::doAuction# Waiting " << *(resultPlayer->getGamePlayer()->getPlayerModel()->getName())<< " action..." ;
	QMutex* mutex = new QMutex();
	QWaitCondition cond;
	mutex->lock();
	for (int i = 0;i<20;i++) { // waiting for action 20 seconds
		qDebug() << "...";
		cond.wait(mutex,1000);
		if (!(resultPlayer->getGamePlayer()->getPlayerModel()->getMessagePool()->isEmpty())) {
			qDebug() << endl << "AuctionAction::doAuction# i got action message from " << *(resultPlayer->getGamePlayer()->getPlayerModel()->getName()) << endl;
			MsvClientMessage* returnMessage = resultPlayer->getGamePlayer()->getPlayerModel()->getMessagePool()->last();
			resultPlayer->getGamePlayer()->getPlayerModel()->getMessagePool()->clear();
			return returnMessage;
		}
	}
	mutex->unlock();
	delete mutex;
	return NULL;
}
开发者ID:mihhailnovik,项目名称:msvPoker,代码行数:19,代码来源:AuctionAction.cpp

示例15: OpenConnection

bool OpenConnection(in_addr_t ipReal, const QString & strClient)
{
	std::map<in_addr_t, Client *>::iterator iterClient, iterOldClient;
	std::map<QString, ClientCreator>::iterator iterCreator;
	bool bSuccess = false;
	Client * pClient;

	g_mutexClients.lock();

	g_pLogger->LogInfo(QString("Starting %1 to host %2...").arg(strClient).arg(IPAddressToString(ipReal)));

	iterCreator = g_mapClientCreators.find(strClient);
	iterClient = g_mapClients.find(ipReal);

	if (iterClient != g_mapClients.end())
	{
		if (iterClient->second != NULL)
		{
			iterClient->second->Stop();
			delete iterClient->second;
		}
		g_mapClients.erase(iterClient);
	}
	if (iterCreator != g_mapClientCreators.end())
		pClient = (*iterCreator->second)();
	else
		pClient = NULL;

	if (pClient != NULL && pClient->Start(ipReal))
		bSuccess = g_mapClients.insert(std::pair<in_addr_t, Client *>(ipReal, pClient)).second;
	else if (pClient != NULL)
		delete pClient;

	if (bSuccess)
		g_pLogger->LogInfo("Successful\n");
	else
		g_pLogger->LogInfo("Failed\n");

	g_mutexClients.unlock();

	return bSuccess;
}
开发者ID:vigneshananth,项目名称:Groovenet-Qt4,代码行数:42,代码来源:Network.cpp


注:本文中的QMutex::unlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。