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


C++ TRINITY_GUARD函数代码示例

本文整理汇总了C++中TRINITY_GUARD函数的典型用法代码示例。如果您正苦于以下问题:C++ TRINITY_GUARD函数的具体用法?C++ TRINITY_GUARD怎么用?C++ TRINITY_GUARD使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: FindBaseMap

Map* MapManager::CreateBaseMap(uint32 id)
{
    Map* map = FindBaseMap(id);

    if (map == NULL)
    {
        TRINITY_GUARD(ACE_Thread_Mutex, Lock);

        MapEntry const* entry = sMapStore.LookupEntry(id);
        ASSERT(entry);

        if (entry->Instanceable())
            map = new MapInstanced(id, i_gridCleanUpDelay);
        else
        {
            map = new Map(id, i_gridCleanUpDelay, 0, REGULAR_DIFFICULTY);
            map->LoadRespawnTimes();
        }

        i_maps[id] = map;
    }

    ASSERT(map);
    return map;
}
开发者ID:Davuk,项目名称:ArkCORE-NG,代码行数:25,代码来源:MapManager.cpp

示例2: TRINITY_GUARD

void WorldLog::outLog(char const* fmt, ...)
{
    if (LogWorld())
    {
        TRINITY_GUARD(ACE_Thread_Mutex, Lock);
        ASSERT(i_file);

        va_list args;
        va_start(args, fmt);
        vfprintf(i_file, fmt, args);
        //fprintf(i_file, "\n");
        va_end(args);

        fflush(i_file);
    }

    if (sLog->GetLogDB() && m_dbWorld)
    {
        va_list ap2;
        va_start(ap2, fmt);
        char nnew_str[MAX_QUERY_LEN];
        vsnprintf(nnew_str, MAX_QUERY_LEN, fmt, ap2);
        sLog->outDB(LOG_TYPE_WORLD, nnew_str);
        va_end(ap2);
    }
}
开发者ID:Jason01ex,项目名称:ZoneLimit,代码行数:26,代码来源:WorldLog.cpp

示例3: TRINITY_GUARD

InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty)
{
    // load/create a map
    TRINITY_GUARD(ACE_Thread_Mutex, Lock);

    // make sure we have a valid map id
    const MapEntry* entry = sMapStore.LookupEntry(GetId());
    if (!entry)
    {
        sLog->outError("CreateInstance: no entry for map %d", GetId());
        ASSERT(false);
    }
    const InstanceTemplate* iTemplate = sObjectMgr->GetInstanceTemplate(GetId());
    if (!iTemplate)
    {
        sLog->outError("CreateInstance: no instance template for map %d", GetId());
        ASSERT(false);
    }

    // some instances only have one difficulty
    GetDownscaledMapDifficultyData(GetId(), difficulty);

    sLog->outDebug(LOG_FILTER_MAPS, "MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");

    InstanceMap* map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
    ASSERT(map->IsDungeon());

    bool load_data = save != NULL;
    map->CreateInstanceData(load_data);

    m_InstancedMaps[InstanceId] = map;
    return map;
}
开发者ID:Blackn7g,项目名称:Voodoo,代码行数:33,代码来源:MapInstanced.cpp

示例4: FindBaseMap

Map* MapManager::CreateBaseMap(uint32 id)
{
    Map* map = FindBaseMap(id);

    if (map == NULL)
    {
        TRINITY_GUARD(ACE_Thread_Mutex, Lock);

        map = FindBaseMap(id);
        if (map == NULL) // pussywizard: check again after acquiring mutex
        {
            MapEntry const* entry = sMapStore.LookupEntry(id);
            ASSERT(entry);

            if (entry->Instanceable())
                map = new MapInstanced(id);
            else
            {
                map = new Map(id, 0, REGULAR_DIFFICULTY);
                map->LoadRespawnTimes();
            }

            i_maps[id] = map;
        }
    }

    ASSERT(map);
    return map;
}
开发者ID:AlexHjelm,项目名称:sunwell,代码行数:29,代码来源:MapManager.cpp

示例5: TRINITY_GUARD

bool InstanceSave::RemovePlayer(uint32 guidLow, InstanceSaveManager* ism)
{
    TRINITY_GUARD(ACE_Thread_Mutex, _lock);
    m_playerList.remove(guidLow);

    // ism passed as an argument to avoid calling via singleton (might result in a deadlock)
    return ism->DeleteInstanceSaveIfNeeded(this->GetInstanceId(), false);
}
开发者ID:Matt-One,项目名称:azerothcore-wotlk,代码行数:8,代码来源:InstanceSaveMgr.cpp

示例6: TRINITY_GUARD

int MapUpdater::wait()
{
    TRINITY_GUARD(ACE_Thread_Mutex, m_mutex);

    while (pending_requests > 0)
        m_condition.wait();

    return 0;
}
开发者ID:GiR-Zippo,项目名称:SkyFire_5xx,代码行数:9,代码来源:MapUpdater.cpp

示例7: while

void AuctionListingRunnable::run()
{
    sLog->outString("Starting up Auction House Listing thread...");
    while (!World::IsStopped())
    {
        if (AsyncAuctionListingMgr::IsAuctionListingAllowed())
        {
            uint32 diff = AsyncAuctionListingMgr::GetDiff();
            AsyncAuctionListingMgr::ResetDiff();

            if (AsyncAuctionListingMgr::GetTempList().size() || AsyncAuctionListingMgr::GetList().size())
            {
                TRINITY_GUARD(ACE_Thread_Mutex, AsyncAuctionListingMgr::GetLock());

                {
                    TRINITY_GUARD(ACE_Thread_Mutex, AsyncAuctionListingMgr::GetTempLock());
                    for (std::list<AuctionListItemsDelayEvent>::iterator itr = AsyncAuctionListingMgr::GetTempList().begin(); itr != AsyncAuctionListingMgr::GetTempList().end(); ++itr)
                        AsyncAuctionListingMgr::GetList().push_back( (*itr) );
                    AsyncAuctionListingMgr::GetTempList().clear();
                }

                for (std::list<AuctionListItemsDelayEvent>::iterator itr = AsyncAuctionListingMgr::GetList().begin(); itr != AsyncAuctionListingMgr::GetList().end(); ++itr)
                {
                    if ((*itr)._msTimer <= diff)
                        (*itr)._msTimer = 0;
                    else
                        (*itr)._msTimer -= diff;
                }

                for (std::list<AuctionListItemsDelayEvent>::iterator itr = AsyncAuctionListingMgr::GetList().begin(); itr != AsyncAuctionListingMgr::GetList().end(); ++itr)
                    if ((*itr)._msTimer == 0)
                    {
                        if ((*itr).Execute())
                            AsyncAuctionListingMgr::GetList().erase(itr);
                        break;
                    }
            }
        }
        ACE_Based::Thread::Sleep(1);
    }
    sLog->outString("Auction House Listing thread exiting without problems.");
}
开发者ID:AzerothShard-Dev,项目名称:azerothcore,代码行数:42,代码来源:WorldRunnable.cpp

示例8: AddSocket

        int AddSocket (WorldSocket* sock)
        {
            TRINITY_GUARD(ACE_Thread_Mutex, m_NewSockets_Lock);

            ++m_Connections;
            sock->AddReference();
            sock->reactor (m_Reactor);
            m_NewSockets.insert (sock);

            sScriptMgr->OnSocketOpen(sock);

            return 0;
        }
开发者ID:mynew2,项目名称:trinitycore-1,代码行数:13,代码来源:WorldSocketMgr.cpp

示例9: TRINITY_GUARD

uint32 MapManager::GetNumInstances()
{
    TRINITY_GUARD(ACE_Thread_Mutex, Lock);

    uint32 ret = 0;
    for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
    {
        Map* map = itr->second;
        if (!map->Instanceable())
            continue;
        MapInstanced::InstancedMaps &maps = ((MapInstanced*)map)->GetInstancedMaps();
        for (MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr)
            if (mitr->second->IsDungeon()) ret++;
    }
    return ret;
}
开发者ID:Davuk,项目名称:ArkCORE-NG,代码行数:16,代码来源:MapManager.cpp

示例10: TRINITY_GUARD

 void VMapManager2::releaseModelInstance(const std::string &filename)
 {
     //! Critical section, thread safe access to iLoadedModelFiles
     TRINITY_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock);
     ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
     if (model == iLoadedModelFiles.end())
     {
         sLog->outError("VMapManager2: trying to unload non-loaded file '%s'", filename.c_str());
         return;
     }
     if (model->second.decRefCount() == 0)
     {
         sLog->outDebug(LOG_FILTER_MAPS, "VMapManager2: unloading file '%s'", filename.c_str());
         delete model->second.getModel();
         iLoadedModelFiles.erase(model);
     }
 }
开发者ID:Bootz,项目名称:SkyFireEMU_430,代码行数:17,代码来源:VMapManager2.cpp

示例11: TRINITY_GUARD

InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty)
{ 
    // load/create a map
    TRINITY_GUARD(ACE_Thread_Mutex, Lock);

    // make sure we have a valid map id
    const MapEntry* entry = sMapStore.LookupEntry(GetId());
    if (!entry)
    {
        sLog->outError("CreateInstance: no entry for map %d", GetId());
        ASSERT(false);
    }
    const InstanceTemplate* iTemplate = sObjectMgr->GetInstanceTemplate(GetId());
    if (!iTemplate)
    {
        sLog->outError("CreateInstance: no instance template for map %d", GetId());
        ASSERT(false);
    }

    // some instances only have one difficulty
    GetDownscaledMapDifficultyData(GetId(), difficulty);

    ;//sLog->outDebug(LOG_FILTER_MAPS, "MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");

    InstanceMap* map = new InstanceMap(GetId(), InstanceId, difficulty, this);
    ASSERT(map->IsDungeon());

    map->LoadRespawnTimes();

    if (save)
        map->CreateInstanceScript(true, save->GetInstanceData(), save->GetCompletedEncounterMask());
    else
        map->CreateInstanceScript(false, "", 0);

    if (!save) // this is for sure a dungeon (assert above), no need to check here
        sInstanceSaveMgr->AddInstanceSave(GetId(), InstanceId, difficulty);

    m_InstancedMaps[InstanceId] = map;
    return map;
}
开发者ID:AzerothShard-Dev,项目名称:azerothcore,代码行数:40,代码来源:MapInstanced.cpp

示例12: FindBaseMap

Map* MapManager::CreateBaseMap(uint32 id)
{
    Map* m = FindBaseMap(id);

    if (m == NULL)
    {
        TRINITY_GUARD(ACE_Thread_Mutex, Lock);

        const MapEntry* entry = sMapStore.LookupEntry(id);
        if (entry && entry->Instanceable())
        {
            m = new MapInstanced(id, i_gridCleanUpDelay);
        }
        else
        {
            m = new Map(id, i_gridCleanUpDelay, 0, REGULAR_DIFFICULTY);
        }
        i_maps[id] = m;
    }

    ASSERT(m != NULL);
    return m;
}
开发者ID:Jason01ex,项目名称:ZoneLimit,代码行数:23,代码来源:MapManager.cpp

示例13: AddNewSockets

        void AddNewSockets()
        {
            TRINITY_GUARD(ACE_Thread_Mutex, m_NewSockets_Lock);

            if (m_NewSockets.empty())
                return;

            for (SocketSet::const_iterator i = m_NewSockets.begin(); i != m_NewSockets.end(); ++i)
            {
                WorldSocket* sock = (*i);

                if (sock->IsClosed())
                {
                    sScriptMgr->OnSocketClose(sock, true);

                    sock->RemoveReference();
                    --m_Connections;
                }
                else
                    m_Sockets.insert (sock);
            }

            m_NewSockets.clear();
        }
开发者ID:mynew2,项目名称:trinitycore-1,代码行数:24,代码来源:WorldSocketMgr.cpp

示例14: defined

// Logon Challenge command handler
bool AuthSocket::_HandleLogonChallenge()
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
    sLog->outDebug(LOG_FILTER_NETWORKIO, "Entering _HandleLogonChallenge");
#endif
    if (socket().recv_len() < sizeof(sAuthLogonChallenge_C))
        return false;

    ///- Session is closed unless overriden
    _status = STATUS_CLOSED;

    // pussywizard: logon flood protection:
    {
        TRINITY_GUARD(ACE_Thread_Mutex, LastLoginAttemptMutex);
        std::string ipaddr = socket().getRemoteAddress();
        uint32 currTime = time(NULL);
        std::map<std::string, uint32>::iterator itr = LastLoginAttemptTimeForIP.find(ipaddr);
        if (itr != LastLoginAttemptTimeForIP.end() && itr->second >= currTime)
        {
            ByteBuffer pkt;
            pkt << uint8(AUTH_LOGON_CHALLENGE);
            pkt << uint8(0x00);
            pkt << uint8(WOW_FAIL_UNKNOWN_ACCOUNT);
            socket().send((char const*)pkt.contents(), pkt.size());
            return true;
        }
        if (LastLoginAttemptCleanTime+60 < currTime)
        {
            LastLoginAttemptTimeForIP.clear();
            LastLoginAttemptCleanTime = currTime;
        }
        else
            LastLoginAttemptTimeForIP[ipaddr] = currTime;
    }

    // Read the first 4 bytes (header) to get the length of the remaining of the packet
    std::vector<uint8> buf;
    buf.resize(4);

    socket().recv((char *)&buf[0], 4);

    EndianConvertPtr<uint16>(&buf[0]);

    uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
    sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] got header, body is %#04x bytes", remaining);
#endif

    if ((remaining < sizeof(sAuthLogonChallenge_C) - buf.size()) || (socket().recv_len() < remaining))
        return false;

    //No big fear of memory outage (size is int16, i.e. < 65536)
    buf.resize(remaining + buf.size() + 1);
    buf[buf.size() - 1] = 0;
    sAuthLogonChallenge_C *ch = (sAuthLogonChallenge_C*)&buf[0];

    // Read the remaining of the packet
    socket().recv((char *)&buf[4], remaining);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
    sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] got full packet, %#04x bytes", ch->size);
    sLog->outDebug(LOG_FILTER_NETWORKIO, "[AuthChallenge] name(%d): '%s'", ch->I_len, ch->I);
#endif

    // BigEndian code, nop in little endian case
    // size already converted
    EndianConvertPtr<uint32>(&ch->gamename[0]);
    EndianConvert(ch->build);
    EndianConvertPtr<uint32>(&ch->platform[0]);
    EndianConvertPtr<uint32>(&ch->os[0]);
    EndianConvertPtr<uint32>(&ch->country[0]);
    EndianConvert(ch->timezone_bias);
    EndianConvert(ch->ip);

    ByteBuffer pkt;

    _login = (const char*)ch->I;
    _build = ch->build;
    _expversion = uint8(AuthHelper::IsPostBCAcceptedClientBuild(_build) ? POST_BC_EXP_FLAG : (AuthHelper::IsPreBCAcceptedClientBuild(_build) ? PRE_BC_EXP_FLAG : NO_VALID_EXP_FLAG));
    _os = (const char*)ch->os;

    if (_os.size() > 4)
        return false;

    // Restore string order as its byte order is reversed
    std::reverse(_os.begin(), _os.end());

    pkt << uint8(AUTH_LOGON_CHALLENGE);
    pkt << uint8(0x00);

    // Verify that this IP is not in the ip_banned table
    LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS));

    std::string const& ip_address = socket().getRemoteAddress();
    PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED);
    stmt->setString(0, ip_address);
    PreparedQueryResult result = LoginDatabase.Query(stmt);
    if (result)
    {
        pkt << uint8(WOW_FAIL_BANNED);
//.........这里部分代码省略.........
开发者ID:lineagedr,项目名称:azerothcore-wotlk,代码行数:101,代码来源:AuthSocket.cpp


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