void COnLine::OnCheckNetCommand() { PXACL_HEADER pHeader = theApp.m_AclFile.GetHeader(); pHeader->bIsCheck = m_CheckUpdate.GetCheck(); m_EditUpdate.EnableWindow(pHeader->bIsCheck); UpdateInterval(); }
//this is called from the vblank run function and from CVideoReferenceClock::Wait in case of a late update void CVideoReferenceClock::UpdateClock(int NrVBlanks, bool CheckMissed) { if (CheckMissed) //set to true from the vblank run function, set to false from Wait and GetTime { if (NrVBlanks < m_MissedVblanks) //if this is true the vblank detection in the run function is wrong CLog::Log(LOGDEBUG, "CVideoReferenceClock: detected %i vblanks, missed %i, refreshrate might have changed", NrVBlanks, m_MissedVblanks); NrVBlanks -= m_MissedVblanks; //subtract the vblanks we missed m_MissedVblanks = 0; } else { m_MissedVblanks += NrVBlanks; //tell the vblank clock how many vblanks it missed m_TotalMissedVblanks += NrVBlanks; //for the codec information screen m_VblankTime += m_SystemFrequency * (int64_t)NrVBlanks / MathUtils::round_int(m_RefreshRate); //set the vblank time forward } if (NrVBlanks > 0) //update the clock with the adjusted frequency if we have any vblanks { double increment = UpdateInterval() * NrVBlanks; double integer = floor(increment); m_CurrTime += (int64_t)(integer + 0.5); //make sure it gets correctly converted to int //accumulate what we lost due to rounding in m_CurrTimeFract, then add the integer part of that to m_CurrTime m_CurrTimeFract += increment - integer; integer = floor(m_CurrTimeFract); m_CurrTime += (int64_t)(integer + 0.5); m_CurrTimeFract -= integer; } }
/* * UpdatePlotTrack updates the plot in a specific track window. */ void UpdatePlotTrack(int itrc, Track *trk) { int k,i; XPoint *plot, *points; Trace *trc= traces[itrc]; if (trc && trc->wave) { float *data= trc->wave->data; if (trc->axis_needScale) { RescaleTrace(trc, trk->height, trk->width); trc->axis_needScale=0; /* no need now */ } /* no clipping, no yoffset */ if (Mode_decimPlot) { PlotWave_decim(trc, &trc->axis, trk->width, trk->height, trk->xwin, trk->gc, 0, 0, itrc); }else { PlotWave(trc, &trc->axis, trk->width, trk->height, trk->xwin, trk->gc, 0, 0, itrc); } /* update zoom track marks, if any */ if (ZoomWindowMapped && (itrc>=lowZTrkIndex) && (itrc<=highZTrkIndex)){ /* now zoomed */ UpdateZTrkMark(itrc, trc, trk); } if (InTrkRange(itrc)) { /* update picks */ DrawPicks(trc->picks, itrc); /* update marked interval(s) */ UpdateInterval(itrc); } } }
// ダイアログの初期化 BOOL CAutoSaveDlg::OnInitDialog () { BOOL bRet = CDialog::OnInitDialog (); ((CSpinButtonCtrl*)GetDlgItem (IDC_AUTOSAVE_INTERVALSP))->SetRange (1, 120); UpdateInterval (); UpdateDisableWhilePlaying (); UpdateDisableWhileRecording (); SetIntervalRange (); return bRet; }
void AnaInterval(cJSON *item) { cJSON *value = cJSON_GetObjectItem(item, "sec"); if (value != NULL && value->type == cJSON_Number) { int interval = (int)(value->valuedouble + 0.0000001); printf("Rcv: Interval: %d\n", interval); UpdateInterval(interval); } }
void COnLine::OnChangeEditUpdateInteral() { CString sUpdateInterval; m_EditUpdate.GetWindowText(sUpdateInterval); BYTE bUpdateInterval = (BYTE)atoi(sUpdateInterval); PXACL_HEADER pHeader = theApp.m_AclFile.GetHeader(); if(bUpdateInterval != pHeader->bUpdateInterval) { pHeader->bUpdateInterval = bUpdateInterval; UpdateInterval(); } }
virtual bool Run() override { while (1) { ULONG loopInterval = UpdateInterval(TaskWorkerInterval); if (CheckKillEvent(loopInterval)) { // Kill Event signaled break; } BR::WeakPointerT<SharedObjectType> localShared; { BR::MutexScopeLock scopeLock(stm_StorageLock); long randID = rand() % MAX_TEST_ID; if (stm_PointerStorage[randID] == nullptr) { BR::MutexScopeLock scopeLock(ThreadGroupOne::stm_StorageLock); if (ThreadGroupOne::stm_PointerStorage[randID] != nullptr) { localShared = ThreadGroupOne::stm_PointerStorage[randID]; stm_PointerStorage[randID] = localShared; } } else { localShared = stm_PointerStorage[randID]; BR::SharedPointerT<SharedObjectType> shared; localShared.GetSharedPointer(shared); if (shared != nullptr) { auto usedCount = shared->pItem->WeakUsedCount.fetch_add(1, std::memory_order_relaxed); if (usedCount > MAX_ACCESS_COUNT) { shared->WeakReleasedCount.fetch_add(1, std::memory_order_relaxed); stm_PointerStorage[randID] = BR::WeakPointerT<SharedObjectType>(); } } } } // Pretend to use Sleep(0); } return true; }
//called from dvdclock to get the time int64_t CVideoReferenceClock::GetTime(bool interpolated /* = true*/) { CSingleLock SingleLock(m_CritSection); //when using vblank, get the time from that, otherwise use the systemclock if (m_UseVblank) { int64_t NextVblank; int64_t Now; Now = CurrentHostCounter(); //get current system time NextVblank = TimeOfNextVblank(); //get time when the next vblank should happen while(Now >= NextVblank) //keep looping until the next vblank is in the future { UpdateClock(1, false); //update clock when next vblank should have happened already NextVblank = TimeOfNextVblank(); //get time when the next vblank should happen } if (interpolated) { //interpolate from the last time the clock was updated double elapsed = (double)(Now - m_VblankTime) * m_ClockSpeed * m_fineadjust; //don't interpolate more than 2 vblank periods elapsed = std::min(elapsed, UpdateInterval() * 2.0); //make sure the clock doesn't go backwards int64_t intTime = m_CurrTime + (int64_t)elapsed; if (intTime > m_LastIntTime) m_LastIntTime = intTime; return m_LastIntTime; } else { return m_CurrTime; } } else { return CurrentHostCounter() + m_ClockOffset; } }
virtual bool Run() override { while (1) { ULONG loopInterval = UpdateInterval(TaskWorkerInterval); if (CheckKillEvent(loopInterval)) { // Kill Event signaled break; } SharedObjectType* sharedPtr = nullptr; BR::SharedPointerT<SharedObjectType> localShared; { BR::MutexScopeLock scopeLock(stm_StorageLock); long randID = rand() % MAX_TEST_ID; if (stm_PointerStorage[randID] == nullptr) { sharedPtr = new SharedObjectType(randID); m_referenceManager.RegisterSharedObject(sharedPtr); localShared = BR::SharedPointerT<SharedObjectType>(sharedPtr); stm_PointerStorage[randID] = localShared; } else { localShared = stm_PointerStorage[randID]; auto usedCount = localShared->pItem->UsedCount.fetch_add(1,std::memory_order_relaxed)+1; if (usedCount > MAX_ACCESS_COUNT) stm_PointerStorage[randID] = BR::SharedPointerT<SharedObjectType>(); } } // Pretend to use Sleep(0); } return true; }
virtual bool Run() override { while (true) { ULONG loopInterval = UpdateInterval(m_TaskWorkerInterval); if (CheckKillEvent(loopInterval)) { // Kill Event signaled break; } BR::WeakPointerT<WorkingEntity> workItem; while (m_WorkItemQueue.try_pop(workItem)) { std::atomic_thread_fence(std::memory_order_acquire); BR::SharedPointerT<WorkingEntity> workObj; workItem.GetSharedPointer(workObj); // If disposed skip item if (workObj == nullptr) { SkippedWorkedItems.fetch_add(1,std::memory_order_relaxed); continue; } // Do some works workObj->pItem->Item = (CounterType)workObj->GetReferenceCount(); // let other threads do some job Sleep(0); workObj->pItem->Item = (CounterType)workObj->GetReferenceCount(); WorkedItems.fetch_add(1, std::memory_order_relaxed); } } return true; }
// 『自動保存をする(ドキュメントが変更されている場合のみ)』 void CAutoSaveDlg::OnChangeOn () { UpdateInterval (); UpdateDisableWhilePlaying (); UpdateDisableWhileRecording (); }