예제 #1
0
 /// \brief Destructor.
 virtual ~ThreadSafeQueue() {
   shutdown_ = true;
   NotifyAll();
   pthread_mutex_destroy(&mutex_);
   pthread_cond_destroy(&condition_empty_);
   pthread_cond_destroy(&condition_full_);
 }
예제 #2
0
ECode BluetoothLeScanner::BleScanCallbackWrapper::OnClientRegistered(
    /* [in] */ Int32 status,
    /* [in] */ Int32 clientIf)
{
    Logger::D(TAG, "onClientRegistered() - status=%d clientIf=%d", status, clientIf);
    {
        AutoLock lock(sLock);
        if (mClientIf == -1) {
            if (DBG)
                Logger::D(TAG, "onClientRegistered LE scan canceled");
        }

        if (status == IBluetoothGatt::GATT_SUCCESS) {
            mClientIf = clientIf;
            //try {
            ECode ec = mBluetoothGatt->StartScan(mClientIf, FALSE, mSettings, mFilters,
                        mResultStorages);
            //} catch (RemoteException e) {
            if (FAILED(ec)) {//need check, maybe only if E_REMOTE_EXCEPTION
                Logger::E(TAG, "fail to start le scan: ");
                mClientIf = -1;
            }
            //}
        } else {
            // registration failed
            mClientIf = -1;
        }
        NotifyAll();
    }
    return NOERROR;
}
예제 #3
0
 // Test that all the threads are notified by a notify_all() call.
 void NotifyAllTest() {
   NotifyAll();
   // Wait briefly to let the lock be re-locked.
   ShortSleep();
   EXPECT_TRUE(m_done1) << "watcher1 failed to be notified.";
   EXPECT_TRUE(m_done2) << "watcher2 failed to be notified.";
 }
예제 #4
0
void CEntityVIPComponent::OnGetVIPDailyReward(GameMsg_Base & rMsg, CSlotPeer & rSlotPeer)
{
    if (IsVIP() && m_VIPInfo.CanGetDailyReward())
    {
        int nExpBonus = 0;
        int nBindMBill = 0;
        std::list<CItem> listItem;
        CVIPDataMgr::Instance().GetDailyExpBonus(m_VIPInfo.m_nLevel, nExpBonus, nBindMBill, listItem);
        m_VIPInfo.m_nLastGetRewardTime = (unsigned int)time(NULL);

        // 奖励
        ChangeVIPInfo(0, nExpBonus, ERoleVipExpCause_AddByDailyReward);
        m_pRoleAttr->ChangeBindBill(nBindMBill, EChangeBindBillCause_Add_VIPDailyReward);
        CItemProcess::AddItems(*(CRoleEntity *)Entity(), listItem, EItemAction_Add_VIPDailyReward, 0, true);

        GameMsg_S2C_GetVIPDailyRewardSuc msgSuc;
        msgSuc.m_nDailyExpBonus = nExpBonus;
        msgSuc.m_nBindMBill = nBindMBill;
        msgSuc.m_listItemReward = listItem;
        SendPlayerMsg(&msgSuc);

        // 通知观察者
        CommonParam param;
        param.SetParam(std::string("activeness"), std::string("vip_daily_reward"));
        NotifyAll(param);
    }
}
예제 #5
0
void AppErrorResult::SetResult(
    /* [in] */ Int32 res)
{
    AutoLock lock(this);
    mHasResult = TRUE;
    mResult = res;
    NotifyAll();
}
예제 #6
0
void UBrainObservable::OnActorCollisionBegin(class AActor* OtherActor)
{
	if (_list_actors_overlap.Num() == 0)
	{
		NotifyAll(true);
		UE_LOG(LogTemp, Warning, TEXT("Begin !"));
	}
	_list_actors_overlap.Add(OtherActor);
}
예제 #7
0
void UBrainObservable::OnActorCollisionEnd(class AActor* OtherActor)
{
	_list_actors_overlap.Remove(OtherActor);
	if (_list_actors_overlap.Num() == 0)
	{
		NotifyAll(false);
		UE_LOG(LogTemp, Warning, TEXT("End !"));
	}
}
예제 #8
0
 // For use when testing predicates. First tries signalling the threads with
 // the predicate set to false (and ensures that they do not activate) and then
 // tests with the predicate set to true.
 void PredicateTest() {
   m_pred_var = false;
   NotifyAll();
   ShortSleep();
   EXPECT_FALSE(m_done1) << "watcher1 didn't pay attention to its predicate.";
   EXPECT_FALSE(m_done2) << "watcher2 didn't pay attention to its predicate.";
   m_pred_var = true;
   NotifyAllTest();
 }
ECode CInputContextCallback::SetExtractedText(
    /* [in] */ IExtractedText* extractedText,
    /* [in] */ Int32 seq)
{
    AutoLock lock(_m_syncLock);

    if (seq == mSeq) {
        mExtractedText = extractedText;
        mHaveValue = TRUE;
        NotifyAll();
    }
    else {
        // Log.i(TAG, "Got out-of-sequence callback " + seq + " (expected " + mSeq
        //         + ") in setExtractedText, ignoring.");
    }

    return NOERROR;
}
ECode CInputContextCallback::SetTextAfterCursor(
    /* [in] */ ICharSequence* textAfterCursor,
    /* [in] */ Int32 seq)
{
    AutoLock lock(_m_syncLock);

    if (seq == mSeq) {
        mTextAfterCursor = textAfterCursor;
        mHaveValue = TRUE;
        NotifyAll();
    }
    else {
        // Log.i(TAG, "Got out-of-sequence callback " + seq + " (expected " + mSeq
        //         + ") in setTextAfterCursor, ignoring.");
    }

    return NOERROR;
}
ECode CInputContextCallback::SetCursorCapsMode(
    /* [in] */ Int32 capsMode,
    /* [in] */ Int32 seq)
{
    AutoLock lock(_m_syncLock);

    if (seq == mSeq) {
        mCursorCapsMode = capsMode;
        mHaveValue = TRUE;
        NotifyAll();
    }
    else {
        // Log.i(TAG, "Got out-of-sequence callback " + seq + " (expected " + mSeq
        //         + ") in setCursorCapsMode, ignoring.");
    }

    return NOERROR;
}
예제 #12
0
ECode HandlerThread::Run()
{
    //TODO mTid = Process::MyTid();
    Looper::Prepare();
    {
        Lock();

        mLooper = Looper::GetMyLooper();
        NotifyAll();

        Unlock();
    }
    //TODO Process::SetThreadPriority(mPriority);
    OnLooperPrepared();
    Looper::Loop();
    mTid = -1;
    return NOERROR;
}
예제 #13
0
void ActivenessComponent::OnNotify(IParam &param)
{
    std::string strActiveModule;
    param.GetParam(std::string("activeness"), strActiveModule);
    int nTargetType = ActivenessTargetConfig::GetTypeFromName(strActiveModule);

    ActivenessTargetConfig  targetConfig;
    if (!ActivenessDataManager::Instance().GetTarget(nTargetType, targetConfig))
    {
        return;
    }

    // 根据当前时间充值活动数据
    ResetActivinessData(time(NULL));

    ActivenessTarget* pTarget = ActivenessTargetFactory::Instance().CreateTarget(targetConfig);
    if (pTarget == NULL)
    {
        return;
    }
    // 用于自动释放内存
    std::auto_ptr<ActivenessTarget> tempPtr(pTarget);

    // 设置数据
    pTarget->SetProgress(GetTargetProgress(nTargetType));
    if (nTargetType == ActivenessTargetConfig::EType_DanceMode)
    {
        ((ActivenessDanceModeTarget*)pTarget)->SetFinishedDanceMode(m_setFinishedDanceMode);
    }

    //目标是否完成
    if (pTarget->IsTargetComplete())
    {
        return;
    }

    // 更新目标进度
    if (pTarget->UpdateProgress(param))
    {
        // 更新component进度
        UpdateTarget(*pTarget);
    }

    // 更新活跃度
    if (pTarget->IsTargetComplete())
    {
        AddActiveness(pTarget->GetTargetScore(), nTargetType);

        if (CanGetReward())
        {
            // 重新通知前端
            SendActivenessInfo();
        }

        // 增加舞团试炼活力值
        CommonParam commonParam;
        commonParam.SetParam("dance_group_active", pTarget->GetTargetScore());
        NotifyAll(commonParam);
    }

    SaveActivinessDataToDb(); // 保存数据
}
예제 #14
0
 /// \brief Tell the queue shut down. This will notify all threads to wake up.
 virtual void Shutdown() final {
   shutdown_ = true;
   NotifyAll();
 }
예제 #15
0
 /// \brief Tell the queue to resume after a shutdown request.
 virtual void Resume() final {
   shutdown_ = false;
   NotifyAll();
 }
예제 #16
0
void CEntityCheckInComponent::OnCheck(GameMsg_Base &msg, CSlotPeer &slotPeer)
{
    ResetByMonthChange();

    GameMsg_C2S_Check & c2smsg = (GameMsg_C2S_Check&)msg;
    int nError = CheckIn(c2smsg.m_nDayIndex);
    if (nError != ECheckInErrorMsg_Success)
    {
        GameMsg_S2C_CheckInFail failmsg;
        failmsg.m_nFailFlag = nError;
        SendPlayerMsg(&failmsg);
    }
    else
    {
        GameMsg_S2C_CheckInSuccess sucmsg;
        sucmsg.m_nDayIndex = c2smsg.m_nDayIndex;
        CCheckInConfig * pCheckInConfig = CCheckInDataManager::Instance().GetCheckInConfig(c2smsg.m_nDayIndex);
        if (pCheckInConfig != NULL)
        {
            int nVipRate = 1;
            if (m_pRoleVip->IsVIP() && m_pRoleVip->VIPLevel() >= (int)pCheckInConfig->m_nVipRewardLevel
                && pCheckInConfig->m_nVipRewardLevel > 0)
            {
                nVipRate = pCheckInConfig->m_nVipRewardRate;
            }

            sucmsg.m_nMoney = pCheckInConfig->m_nMoney*nVipRate;
            sucmsg.m_nBindCoin = pCheckInConfig->m_nBindCoin*nVipRate;
            sucmsg.m_ItemReward = m_pRoleAttr->GetSex() == ESexType_Male ? pCheckInConfig->m_maleItemReward : pCheckInConfig->m_femaleItemReward;

            if (m_pRoleAttr->GetSex() == ESexType_Male)
            {
                CItem maleitem(pCheckInConfig->m_maleItemReward);
                ItemConfig * pItemInfo = ConfigManager::Instance().GetItemConfigManager().GetByID(pCheckInConfig->m_maleItemReward.m_nItemType);
                if (pItemInfo != NULL)
                {
                    if (pItemInfo->IsEquip())
                    {
                        if (nVipRate > 1)
                        {
                            maleitem.m_nValidTime = -1;
                        }
                    }
                    else
                    {
                        maleitem.m_nItemCount = (itemcount_t)(maleitem.m_nItemCount*nVipRate);
                    }
                    sucmsg.m_ItemReward = maleitem;
                }
            }
            else
            {
                CItem femaleitem(pCheckInConfig->m_femaleItemReward);
                ItemConfig * pItemInfo = ConfigManager::Instance().GetItemConfigManager().GetByID(pCheckInConfig->m_femaleItemReward.m_nItemType);
                if (pItemInfo != NULL)
                {
                    if (pItemInfo->IsEquip())
                    {
                        if (nVipRate > 1)
                        {
                            femaleitem.m_nValidTime = -1;
                        }
                    }
                    else
                    {
                        femaleitem.m_nItemCount = (itemcount_t)(femaleitem.m_nItemCount*nVipRate);
                    }

                    sucmsg.m_ItemReward = femaleitem;
                }
            }
        }
        SendPlayerMsg(&sucmsg);

        // 通知其它系统
        CommonParam param;
        param.SetParam(std::string("activeness"), std::string("checkin"));
        NotifyAll(param);
    }
}
예제 #17
0
void AbstractOutputNode::Send(std::vector<int> value)
{
    valueBuf = value;
    NotifyAll();
}
예제 #18
0
void CEntityVIPComponent::ChangeVIPInfo(unsigned int nAddTime, unsigned int nAddExp, ERoleVipExpCause eCause)
{
    bool bIsOpenAction = false;
    bool bIsExpiredToday = m_VIPInfo.IsExpiredToday();
    if (nAddTime > 0)
    {
        int nNow = (int)time(NULL);
        if (m_VIPInfo.m_nExpiredTime < (long long)nNow)
        {
            m_VIPInfo.m_nExpiredTime = (long long)nNow + (long long)nAddTime;
            bIsOpenAction = true;
        }
        else
        {
            m_VIPInfo.m_nExpiredTime += (long long)nAddTime;
        }

        LogVipDuration(nAddTime);
    }

    int nOldLevel = m_VIPInfo.m_nLevel;
    if (nAddExp > 0)
    {
        m_VIPInfo.m_nExp += nAddExp;
        LogVipExp(eCause, nAddExp);

        while (m_VIPInfo.m_nExp >= (int)CVIPDataMgr::Instance().GetExpLevelUpNeed(m_VIPInfo.m_nLevel)
            && m_VIPInfo.m_nLevel < CVIPDataMgr::Instance().GetMaxLevel())
        {
            int nExpNeed = CVIPDataMgr::Instance().GetExpLevelUpNeed(m_VIPInfo.m_nLevel);
            m_VIPInfo.m_nExp -= nExpNeed;
            ++m_VIPInfo.m_nLevel;
            SendVIPLevelUpReward();
            VIPLevelUpAnnounce(m_VIPInfo.m_nLevel);

            LogVipExp(ERoleVipExpCause_DelByLevelUp, -nExpNeed);
        }

        if (m_VIPInfo.m_nLevel > nOldLevel)
        {
            LevelUpRewardNotification(m_VIPInfo.m_nLevel);
            LogVipLevelUp(m_VIPInfo.m_nLevel);
            m_pRoleItem->UpdateStorageCapacity(m_VIPInfo.m_nLevel);
        }
    }

    if (nAddTime > 0 || nAddExp > 0)
    {
        m_VIPInfo.m_bValid = true;
        OnVIPInfoChanged(nOldLevel, m_VIPInfo.m_nLevel);
        NotifyClientUpdateVIPInfo();
        UpdateVIPInfoToDB();

        // 开启vip
        if (bIsOpenAction)
        {
            m_pRoleCheckIn->ReissueRewardByVipOpen(m_VIPInfo.m_nLevel);
        }
        else if (IsVIP() && m_VIPInfo.m_nLevel > nOldLevel)
        {
            m_pRoleCheckIn->ReissueRewardByVipLevelChange(nOldLevel, m_VIPInfo.m_nLevel);
        }

        unsigned short nOldExtraChance = 0, nNewExtraChance = 0;
        const CVIPLevelPrivInfo *pPrivData = NULL;

        if (nOldLevel != 0)
        {
            pPrivData = CVIPDataMgr::Instance().GetVIPPrivInfo(nOldLevel);
            if (pPrivData != NULL)
            {
                nOldExtraChance = pPrivData->m_nDanceGroupChallengeExtraChance;

            }
        }
        if (m_VIPInfo.m_nLevel != 0)
        {
            pPrivData = CVIPDataMgr::Instance().GetVIPPrivInfo(m_VIPInfo.m_nLevel);
            if (pPrivData != NULL)
            {
                nNewExtraChance = pPrivData->m_nDanceGroupChallengeExtraChance;
            }
        }

        // 通知观察者
        CommonParam param;
        param.SetParam(std::string("medal"), std::string("vip"));
        param.SetParam(std::string("vip_level"), m_VIPInfo.m_nLevel);
        if (nOldExtraChance < nNewExtraChance)
        {
            param.SetParam("add_challenge_chance", nNewExtraChance - nOldExtraChance);
        }
        else if (bIsOpenAction && !bIsExpiredToday)
        {
            param.SetParam("add_challenge_chance", nOldExtraChance);
        }
        NotifyAll(param);
    }
}