SessionCatalogMigrationSource::OplogResult SessionCatalogMigrationSource::getLastFetchedOplog() { { stdx::lock_guard<stdx::mutex> _lk(_sessionCloneMutex); if (_lastFetchedOplog) { return OplogResult(_lastFetchedOplog, false); } } { stdx::lock_guard<stdx::mutex> _lk(_newOplogMutex); return OplogResult(_lastFetchedNewWriteOplog, true); } }
std::shared_ptr<T> wait_and_pop() { std::unique_lock<std::mutex> _lk(_m); _data.wait(_lk, [this] { return !_data.empty(); }); std::shared_ptr<T> res( std::make_shared<T>(std::move(_data.front()))); _data.pop_front(); return res; }
void SessionCatalogMigrationSource::onCloneCleanup() { stdx::lock_guard<stdx::mutex> _lk(_newOplogMutex); _state = State::kCleanup; if (_newOplogNotification) { _newOplogNotification->set(true); _newOplogNotification.reset(); } }
void SessionCatalogMigrationSource::onCommitCloneStarted() { stdx::lock_guard<stdx::mutex> _lk(_newOplogMutex); _state = State::kCommitStarted; if (_newOplogNotification) { _newOplogNotification->set(true); _newOplogNotification.reset(); } }
bool try_pop_tail(T &value) { std::lock_guard<std::mutex> _lk(_m); if (_data.empty()) { return false; } value = std::move(_data.back()); _data.pop_back(); return true; }
void CFileDownloader::_CloseFileHandler() { autolock<CThreadGuard> _lk(m_thLocker); if(m_hFile) { if(m_hFile!=INVALID_HANDLE_VALUE) CloseHandle(m_hFile); m_hFile = NULL; } }
void self_iterating(const int enqueue_time) { self_iterate_context ctx; for (int i = 0; i < enqueue_time; i++) { auto tsk = new task_c(LPC_TEST_TASK_QUEUE_1, iterate_over_preallocated_tasks, &ctx, nullptr); ctx.tsks.push_back(tsk); } ctx.it = ctx.tsks.begin(); { auto_timer t("self-iterating test:", enqueue_time); iterate_over_preallocated_tasks(&ctx); std::unique_lock<std::mutex> _lk(ctx.mut); ctx.cv.wait(_lk, [&] {return ctx.done;}); } }
bool SessionCatalogMigrationSource::_hasMoreOplogFromSessionCatalog() { stdx::lock_guard<stdx::mutex> _lk(_sessionCloneMutex); return _lastFetchedOplog || !_lastFetchedOplogBuffer.empty() || !_sessionOplogIterators.empty() || _currentOplogIterator; }
size_t size() const { std::lock_guard<std::mutex> _lk(_m); return _data.size(); }
bool empty() const { std::lock_guard<std::mutex> _lk(_m); return _data.empty(); }
void wait_and_pop(T &value) { std::unique_lock<std::mutex> _lk(_m); _cond.wait(_lk, [this] { return !_data.empty(); }); value = std::move(_data.front()); _data.pop_front(); }
void push(T new_value) { std::lock_guard<std::mutex> _lk(_m); _data.push_back(std::move(new_value)); _cond.notify_one(); }
void CSysEnv::Init() { static CThreadGuard locker; autolock<CThreadGuard> _lk(locker); lang = GetLangID(); isAdmin = IsAdministratorUser(); isWin64 = IsWin64(); static ISoftInfo *pWindowsInfo=NULL; m_pOfficeInfo = NULL; if(m_arrSofts.GetSize()==0) { pWindowsInfo = new CWindowsInfo; m_arrSofts.Add( pWindowsInfo ); m_arrSofts.Add( new CInternetExplorer ); m_arrSofts.Add( new CWSScriptInfo ); m_arrSofts.Add( new CMediaplayerInfo ); m_arrSofts.Add( new CDirectXInfo ); m_arrSofts.Add( new COutLookExpressInfo ); m_arrSofts.Add( new CDataAccessInfo ); m_arrSofts.Add( new CDotNetFrameworkInfo ); m_arrSofts.Add( new CXmlCoreInfo ); } for(int i=0; i<m_arrSofts.GetSize(); ++i) { m_arrSofts[i]->TryReadInfo(); } if(pWindowsInfo) { m_WinVer = pWindowsInfo->m_nVer; m_WinSP = pWindowsInfo->m_nSP; } #if 0 CString strAll; // 系统 static LPCTSTR szTitles[] = { _T("Windows"), _T("IE"), _T("Script"), _T("MediaPlayer"), _T("DirectX"), _T("Outlook"), _T("DataAccess"), _T("DotFramework"), _T("Xml"), }; strAll.Format(_T("ISAdmin:%d IsWin64:%d Lang:%d\n"), isAdmin?1:0, isWin64?1:0, lang); for(int i=0; i<m_arrSofts.GetSize(); ++i) { strAll.AppendFormat(_T("%s : %d - %d \n"), szTitles[i], m_arrSofts[i]->m_nVer, m_arrSofts[i]->m_nSP); } MessageBox(NULL, strAll, NULL, MB_OK); #endif }