bool Node::deserialize( std::string& data ) { LBASSERT( _impl->state == STATE_CLOSED ); // version check int32_t major = 0; size_t nextPos = data.find( CO_SEPARATOR ); if( nextPos == std::string::npos || nextPos == 0 ) { LBERROR << "Could not parse node major version data" << std::endl; return false; } std::istringstream is( data.substr( 0, nextPos )); data = data.substr( nextPos + 1 ); is >> major; int32_t minor = 0; nextPos = data.find( CO_SEPARATOR ); if( nextPos == std::string::npos || nextPos == 0 ) { LBERROR << "Could not parse node minor version data" << std::endl; return false; } is.clear(); is.str( data.substr( 0, nextPos )); data = data.substr( nextPos + 1 ); is >> minor; if( major != Version::getMajor() || minor != Version::getMinor( )) { LBWARN << "Protocol mismatch: remote node uses version " << major << '.' << minor << ", local node uses " << Version::getMajor() << '.' << Version::getMinor() << std::endl; } // node id nextPos = data.find( CO_SEPARATOR ); if( nextPos == std::string::npos || nextPos == 0 ) { LBERROR << "Could not parse node id data" << std::endl; return false; } _impl->id = data.substr( 0, nextPos ); data = data.substr( nextPos + 1 ); // endianness nextPos = data.find( CO_SEPARATOR ); if( nextPos == std::string::npos || nextPos == 0 ) { LBERROR << "Could not parse node endianness data" << std::endl; return false; } is.clear(); is.str( data.substr( 0, nextPos )); data = data.substr( nextPos + 1 ); is >> _impl->bigEndian; // Connections data lunchbox::ScopedFastWrite mutex( _impl->connectionDescriptions ); _impl->connectionDescriptions->clear(); return co::deserialize( data, _impl->connectionDescriptions.data ); }
void EEFadeProcess(EEObject* _object, float _time, float _degree, float _delay, float _startTime) { try { float remainTime = _delay + _time; float progress = _startTime; float speed = (_degree - _object->GetAlpha()) / _time; if (remainTime <= 0.f) { _object->SetAlpha(_degree); return; } else if (_delay < 0.f) { float deltaAlpha = speed * (-_delay); _object->SetAlpha(_object->GetAlpha() + deltaAlpha); } else { while (1) { EEThreadSleep(10); std::lock_guard<std::mutex> mutex(_object->GetThreadMutex()); float currTime = (float)EECore::s_EECore->GetTotalTime(); float deltaTime = currTime - progress; progress = currTime; if (remainTime <= deltaTime + _time) { progress -= _time - (remainTime - deltaTime); remainTime = _time; break; } else { remainTime -= deltaTime; } } } while (1) { EEThreadSleep(10); std::lock_guard<std::mutex> mutex(_object->GetThreadMutex()); float currTime = (float)EECore::s_EECore->GetTotalTime(); float deltaTime = currTime - progress; progress = currTime; if (remainTime <= deltaTime) { float deltaAlpha = speed * remainTime; _object->SetAlpha(_object->GetAlpha() + deltaAlpha); remainTime = 0.f; return; } else { float deltaAlpha = speed * deltaTime; _object->SetAlpha(_object->GetAlpha() + deltaAlpha); remainTime -= deltaTime; } } } catch (boost::thread_interrupted&) { return; } }
void FrameBuffer::DestroyWindowSurface(HandleType p_surface) { android::Mutex::Autolock mutex(m_lock); m_windows.erase(p_surface); }
void lock() { mutex().lock(); }
void CVerifyCertDialog::LoadTrustedCerts() { CReentrantInterProcessMutexLocker mutex(MUTEX_TRUSTEDCERTS); if (!m_xmlFile.Modified()) { return; } TiXmlElement* pElement = m_xmlFile.Load(); if (!pElement) { return; } m_trustedCerts.clear(); if (!(pElement = pElement->FirstChildElement("TrustedCerts"))) return; bool modified = false; TiXmlElement* pCert = pElement->FirstChildElement("Certificate"); while (pCert) { wxString value = GetTextElement(pCert, "Data"); TiXmlElement* pRemove = 0; t_certData data; if (value.empty() || !(data.data = ConvertStringToHex(value, data.len))) pRemove = pCert; data.host = GetTextElement(pCert, "Host"); data.port = GetTextElementInt(pCert, "Port"); if (data.host.empty() || data.port < 1 || data.port > 65535) pRemove = pCert; wxLongLong activationTime = GetTextElementLongLong(pCert, "ActivationTime", 0); if (activationTime == 0 || activationTime > wxDateTime::GetTimeNow()) pRemove = pCert; wxLongLong expirationTime = GetTextElementLongLong(pCert, "ExpirationTime", 0); if (expirationTime == 0 || expirationTime < wxDateTime::GetTimeNow()) pRemove = pCert; if (IsTrusted(data.host, data.port, data.data, data.len, true)) // Weed out duplicates pRemove = pCert; if (!pRemove) m_trustedCerts.push_back(data); else delete [] data.data; pCert = pCert->NextSiblingElement("Certificate"); if (pRemove) { modified = true; pElement->RemoveChild(pRemove); } } if (modified) m_xmlFile.Save(false); }
DWORD DbgHelp::UnDecorateSymbolName(PCSTR decoratedName, PSTR undecoratedName, DWORD undecoratedLength, DWORD flags) const { Guard lock(mutex()); return mUnDecorateSymbolName(decoratedName, undecoratedName, undecoratedLength, flags); }
void Data::addData(int data) { std::lock_guard<std::mutex> mutex(access); messages.push(data); }
BOOL DbgHelp::SymGetModuleInfo64(DWORD64 address, PIMAGEHLP_MODULE64 moduleInfo) const { Guard lock(mutex()); return mSymGetModuleInfo64(mProcess, address, moduleInfo); }
DWORD64 DbgHelp::SymLoadModule64(HANDLE file, PCSTR imageName, PCSTR moduleName, DWORD64 baseOfDll, DWORD sizeOfDll) const { Guard lock(mutex()); return mSymLoadModule64(mProcess, file, imageName, moduleName, baseOfDll, sizeOfDll); }
void CFilterManager::LoadFilters() { if (m_loaded) return; m_loaded = true; CInterProcessMutex mutex(MUTEX_FILTERS); wxFileName file(wxGetApp().GetSettingsDir(), _T("filters.xml")); if (!file.FileExists()) { wxFileName defaults(wxGetApp().GetResourceDir(), _T("defaultfilters.xml")); if (defaults.FileExists()) { TiXmlElement* pDocument = GetXmlFile(defaults); if (pDocument) { SaveXmlFile(file, pDocument); delete pDocument->GetDocument(); } } } CXmlFile xml(file); TiXmlElement* pDocument = xml.Load(); if (!pDocument) { wxString msg = xml.GetError() + _T("\n\n") + _("Any changes made to the filters will not be saved."); wxMessageBox(msg, _("Error loading xml file"), wxICON_ERROR); return; } TiXmlElement *pFilters = pDocument->FirstChildElement("Filters"); if (!pFilters) return; TiXmlElement *pFilter = pFilters->FirstChildElement("Filter"); while (pFilter) { CFilter filter; filter.name = GetTextElement(pFilter, "Name"); if (filter.name == _T("")) { pFilter = pFilter->NextSiblingElement("Filter"); continue; } filter.filterFiles = GetTextElement(pFilter, "ApplyToFiles") == _T("1"); filter.filterDirs = GetTextElement(pFilter, "ApplyToDirs") == _T("1"); wxString type = GetTextElement(pFilter, "MatchType"); if (type == _T("Any")) filter.matchType = CFilter::any; else if (type == _T("None")) filter.matchType = CFilter::none; else filter.matchType = CFilter::all; filter.matchCase = GetTextElement(pFilter, "MatchCase") == _T("1"); TiXmlElement *pConditions = pFilter->FirstChildElement("Conditions"); if (!pConditions) { pFilter = pFilter->NextSiblingElement("Filter"); continue; } TiXmlElement *pCondition = pConditions->FirstChildElement("Condition"); while (pCondition) { CFilterCondition condition; int type = GetTextElementInt(pCondition, "Type", 0); switch (type) { case 0: condition.type = filter_name; break; case 1: condition.type = filter_size; break; case 2: condition.type = filter_attributes; break; case 3: condition.type = filter_permissions; break; case 4: condition.type = filter_path; break; default: pCondition = pCondition->NextSiblingElement("Condition"); continue; } condition.condition = GetTextElementInt(pCondition, "Condition", 0); condition.strValue = GetTextElement(pCondition, "Value"); condition.matchCase = filter.matchCase; if (condition.strValue == _T("")) { pCondition = pCondition->NextSiblingElement("Condition"); continue; } // TODO: 64bit filesize if (condition.type == filter_size) { unsigned long tmp; condition.strValue.ToULong(&tmp); condition.value = tmp; } else if (condition.type == filter_attributes || condition.type == filter_permissions) { if (condition.strValue == _T("0")) condition.value = 0; else condition.value = 1; } filter.filters.push_back(condition); pCondition = pCondition->NextSiblingElement("Condition"); } if (!filter.filters.empty()) m_globalFilters.push_back(filter); pFilter = pFilter->NextSiblingElement("Filter"); } CompileRegexes(); TiXmlElement* pSets = pDocument->FirstChildElement("Sets"); if (!pSets) return; for (TiXmlElement* pSet = pSets->FirstChildElement("Set"); pSet; pSet = pSet->NextSiblingElement("Set")) { CFilterSet set; TiXmlElement* pItem = pSet->FirstChildElement("Item"); while (pItem) { wxString local = GetTextElement(pItem, "Local"); wxString remote = GetTextElement(pItem, "Remote"); set.local.push_back(local == _T("1") ? true : false); set.remote.push_back(remote == _T("1") ? true : false); pItem = pItem->NextSiblingElement("Item"); } if (!m_globalFilterSets.empty()) { set.name = GetTextElement(pSet, "Name"); if (set.name == _T("")) continue; } if (set.local.size() == m_globalFilters.size()) m_globalFilterSets.push_back(set); } wxString attribute = GetTextAttribute(pSets, "Current"); unsigned long value; if (attribute.ToULong(&value)) { if (value < m_globalFilterSets.size()) m_globalCurrentFilterSet = value; } }
bool Config::handleEvent( const ConfigEvent* event ) { switch( event->data.type ) { case Event::EXIT: case Event::WINDOW_CLOSE: _running = false; return true; case Event::KEY_PRESS: if( event->data.keyPress.key == KC_ESCAPE ) { _running = false; return true; } break; case Event::WINDOW_POINTER_BUTTON_PRESS: case Event::CHANNEL_POINTER_BUTTON_PRESS: if( event->data.pointerButtonPress.buttons == ( PTR_BUTTON1 | PTR_BUTTON2 | PTR_BUTTON3 )) { _running = false; return true; } break; case Event::STATISTIC: { EQLOG( LOG_STATS ) << event->data << std::endl; const uint32_t originator = event->data.serial; EQASSERTINFO( originator != EQ_INSTANCE_INVALID, event->data ); if( originator == 0 ) return false; const Statistic& statistic = event->data.statistic; const uint32_t frame = statistic.frameNumber; EQASSERT( statistic.type != Statistic::NONE ) if( frame == 0 || // Not a frame-related stat event or statistic.type == Statistic::NONE ) // No event-type set { return false; } co::base::ScopedMutex< co::base::SpinLock > mutex( _statistics ); for( std::deque<FrameStatistics>::iterator i =_statistics->begin(); i != _statistics->end(); ++i ) { FrameStatistics& frameStats = *i; if( frameStats.first == frame ) { SortedStatistics& sortedStats = frameStats.second; Statistics& statistics = sortedStats[ originator ]; statistics.push_back( statistic ); return false; } } _statistics->push_back( FrameStatistics( )); FrameStatistics& frameStats = _statistics->back(); frameStats.first = frame; SortedStatistics& sortedStats = frameStats.second; Statistics& statistics = sortedStats[ originator ]; statistics.push_back( statistic ); return false; } case Event::VIEW_RESIZE: { EQASSERT( event->data.originator != UUID::ZERO ); View* view = find< View >( event->data.originator ); if( view ) return view->handleEvent( event->data ); break; } } return false; }
void CFilterDialog::SaveFilters() { CInterProcessMutex mutex(MUTEX_FILTERS); wxFileName file(wxGetApp().GetSettingsDir(), _T("filters.xml")); CXmlFile xml(file); TiXmlElement* pDocument = xml.Load(); if (!pDocument) { wxString msg = xml.GetError() + _T("\n\n") + _("Any changes made to the filters could not be saved."); wxMessageBox(msg, _("Error loading xml file"), wxICON_ERROR); return; } TiXmlElement *pFilters = pDocument->FirstChildElement("Filters"); while (pFilters) { pDocument->RemoveChild(pFilters); pFilters = pDocument->FirstChildElement("Filters"); } pFilters = pDocument->InsertEndChild(TiXmlElement("Filters"))->ToElement(); for (std::vector<CFilter>::const_iterator iter = m_globalFilters.begin(); iter != m_globalFilters.end(); iter++) { const CFilter& filter = *iter; TiXmlElement* pFilter = pFilters->InsertEndChild(TiXmlElement("Filter"))->ToElement(); AddTextElement(pFilter, "Name", filter.name); AddTextElement(pFilter, "ApplyToFiles", filter.filterFiles ? _T("1") : _T("0")); AddTextElement(pFilter, "ApplyToDirs", filter.filterDirs ? _T("1") : _T("0")); AddTextElement(pFilter, "MatchType", (filter.matchType == CFilter::any) ? _T("Any") : ((filter.matchType == CFilter::none) ? _T("None") : _T("All"))); AddTextElement(pFilter, "MatchCase", filter.matchCase ? _T("1") : _T("0")); TiXmlElement* pConditions = pFilter->InsertEndChild(TiXmlElement("Conditions"))->ToElement(); for (std::vector<CFilterCondition>::const_iterator conditionIter = filter.filters.begin(); conditionIter != filter.filters.end(); conditionIter++) { const CFilterCondition& condition = *conditionIter; TiXmlElement* pCondition = pConditions->InsertEndChild(TiXmlElement("Condition"))->ToElement(); int type; switch (condition.type) { case filter_name: type = 0; break; case filter_size: type = 1; break; case filter_attributes: type = 2; break; case filter_permissions: type = 3; break; case filter_path: type = 4; break; default: wxFAIL_MSG(_T("Unhandled filter type")); break; } AddTextElement(pCondition, "Type", type); AddTextElement(pCondition, "Condition", condition.condition); AddTextElement(pCondition, "Value", condition.strValue); } } TiXmlElement *pSets = pDocument->FirstChildElement("Sets"); while (pSets) { pDocument->RemoveChild(pSets); pSets = pDocument->FirstChildElement("Sets"); } pSets = pDocument->InsertEndChild(TiXmlElement("Sets"))->ToElement(); SetTextAttribute(pSets, "Current", wxString::Format(_T("%d"), m_currentFilterSet)); for (std::vector<CFilterSet>::const_iterator iter = m_globalFilterSets.begin(); iter != m_globalFilterSets.end(); iter++) { const CFilterSet& set = *iter; TiXmlElement* pSet = pSets->InsertEndChild(TiXmlElement("Set"))->ToElement(); if (iter != m_globalFilterSets.begin()) AddTextElement(pSet, "Name", set.name); for (unsigned int i = 0; i < set.local.size(); i++) { TiXmlElement* pItem = pSet->InsertEndChild(TiXmlElement("Item"))->ToElement(); AddTextElement(pItem, "Local", set.local[i] ? _T("1") : _T("0")); AddTextElement(pItem, "Remote", set.remote[i] ? _T("1") : _T("0")); } } xml.Save(); m_filters_disabled = false; }
void CPFWindow::ShowStatus(void) { StMutex mutex(*this); static int ID; if(mDead || !mPFoneFrame) return; switch(mState) { case _cs_none: case _cs_uninitialized: case _cs_listening: mRemoteIDStatic.ShowWindow(SW_HIDE); mRemoteIDTitleStatic.ShowWindow(SW_HIDE); if( gHardwareIsFullDuplex ) { mTalkButton.SetWindowText("Test"); mTalkButton.ShowWindow(SW_SHOW); } mCallComboBox.ShowWindow(SW_SHOW); mConnectButton.ShowWindow(SW_SHOW); if(gPGFOpts.popt.connection == _cme_Serial) { mConnectButton.SetWindowText("Dial"); mLocalIPStatic.ShowWindow(SW_HIDE); mLocalIPTitleStatic.ShowWindow(SW_HIDE); } else { mConnectButton.SetWindowText("Connect"); mLocalIPStatic.ShowWindow(SW_SHOW); mLocalIPTitleStatic.ShowWindow(SW_SHOW); } mDecoderComboBox.EnableWindow(FALSE); mCoderComboBox.EnableWindow(FALSE); //SetDefID(IDC_DIAL); break; case _cs_connected: mConnectButton.SetWindowText("Hangup"); mConnectButton.ShowWindow(SW_SHOW); if(mControlThread->GetControlState() == _con_Phone) { SetSpeaker(mTalkFlag, mFullDuplex); mTalkButton.ShowWindow(SW_SHOW); mDecoderComboBox.EnableWindow(TRUE); mCoderComboBox.EnableWindow(TRUE); //SetDefID(IDC_TALK_LISTEN); } else { if( !gHardwareIsFullDuplex ) mTalkButton.ShowWindow(SW_HIDE); mDecoderComboBox.EnableWindow(FALSE); mCoderComboBox.EnableWindow(FALSE); //SetDefID(IDC_DIAL); } ShowCaller(); break; case _cs_calldetected: mCallComboBox.ShowWindow(SW_HIDE); mConnectButton.SetWindowText("Answer"); ShowCaller(); //SetDefID(IDC_DIAL); break; case _cs_connecting: case _cs_disconnecting: mCallComboBox.ShowWindow(SW_HIDE); mConnectButton.ShowWindow(SW_SHOW); if( !gHardwareIsFullDuplex ) mTalkButton.ShowWindow(SW_HIDE); mConnectButton.SetWindowText("Hangup"); mDecoderComboBox.EnableWindow(FALSE); mCoderComboBox.EnableWindow(FALSE); //SetDefID(IDC_DIAL); break; case _cs_initializing: mCallComboBox.ShowWindow(SW_HIDE); mConnectButton.ShowWindow(SW_SHOW); if( !gHardwareIsFullDuplex ) mTalkButton.ShowWindow(SW_HIDE); mConnectButton.SetWindowText("Cancel"); mDecoderComboBox.EnableWindow(FALSE); mCoderComboBox.EnableWindow(FALSE); //SetDefID(IDC_DIAL); break; } switch(mState) { case _cs_listening: mStatusBar = "Waiting for call"; mPFoneFrame->setStatusPhoneIconID(IDR_WAITING); break; case _cs_none: case _cs_uninitialized: mStatusBar = "None"; mPFoneFrame->setStatusPhoneIconID(0); break; case _cs_connected: switch(mControlThread->GetControlState()) { default: case _con_Configuring: mStatusBar = "Configuring"; break; case _con_Phone: if(!memcmp(&mCryptor, "NONE", 4)) mPFoneFrame->setStatusSecureIconID(IDR_INSECURE); else mPFoneFrame->setStatusSecureIconID(IDR_SECURE); break; case _con_Disconnecting: mStatusBar = "Confirming Hangup"; break; } mPFoneFrame->setStatusPhoneIconID(IDR_CONNECTED); break; case _cs_calldetected: mStatusBar = "Ring"; break; case _cs_connecting: mStatusBar = "Connecting"; mPFoneFrame->setStatusPhoneIconID(IDR_CONNECTED); break; case _cs_disconnecting: mStatusBar = "Disconnecting"; mPFoneFrame->setStatusPhoneIconID(IDR_CONNECTED); break; case _cs_initializing: mStatusBar = "Initializing modem"; break; default: pgp_errstring("unknown status"); } if(mState != _cs_connected) mPFoneFrame->setStatusSecureIconID(ID); }
//=============================== bs_signal implementation ============================================================= bs_signal::bs_signal(int signal_code) : pimpl_(new signal_impl(signal_code), mutex(), bs_static_cast()) {}
DWORD DbgHelp::SymSetOptions(DWORD options) const { Guard lock(mutex()); return mSymSetOptions(options); }
BOOL DbgHelp::SymInitialize(PCSTR searchPath, BOOL invadeProcess) const { Guard lock(mutex()); return mSymInitialize(mProcess, searchPath, invadeProcess); }
DWORD DbgHelp::SymGetOptions() const { Guard lock(mutex()); return mSymGetOptions(); }
BOOL DbgHelp::SymUnloadModule64(DWORD64 baseOfDll) const { Guard lock(mutex()); return mSymUnloadModule64(mProcess, baseOfDll); }
BOOL DbgHelp::SymUnDName64(PIMAGEHLP_SYMBOL64 symbol, PSTR undecoratedName, DWORD undecoratedLength) const { Guard lock(mutex()); return mSymUnDName64(symbol, undecoratedName, undecoratedLength); }
BOOL DbgHelp::SymEnumerateModules64(PSYM_ENUMMODULES_CALLBACK64 enumModulesCallback, PVOID userContext) const { Guard lock(mutex()); return mSymEnumerateModules64(mProcess, enumModulesCallback, userContext); }
void CClearPrivateDataDialog::Show() { if (!Load(m_pMainFrame, _T("ID_CLEARPRIVATEDATA"))) return; if (ShowModal() != wxID_OK) return; wxCheckBox *pSitemanagerCheck = XRCCTRL(*this, "ID_CLEARSITEMANAGER", wxCheckBox); wxCheckBox *pQueueCheck = XRCCTRL(*this, "ID_CLEARQUEUE", wxCheckBox); if (pSitemanagerCheck->GetValue() && pQueueCheck->GetValue()) { int res = wxMessageBox(_("Do you really want to delete all Site Manager entries and the transfer queue?"), _("Clear private data"), wxYES | wxNO | wxICON_QUESTION); if (res != wxYES) return; } else if (pQueueCheck->GetValue()) { int res = wxMessageBox(_("Do you really want to delete the transfer queue?"), _("Clear private data"), wxYES | wxNO | wxICON_QUESTION); if (res != wxYES) return; } else if (pSitemanagerCheck->GetValue()) { int res = wxMessageBox(_("Do you really want to delete all Site Manager entries?"), _("Clear private data"), wxYES | wxNO | wxICON_QUESTION); if (res != wxYES) return; } wxCheckBox *pCheck = XRCCTRL(*this, "ID_CLEARQUICKCONNECT", wxCheckBox); if (!pCheck) return; if (pCheck->GetValue()) { CRecentServerList::Clear(); if (m_pMainFrame->GetQuickconnectBar()) m_pMainFrame->GetQuickconnectBar()->ClearFields(); } pCheck = XRCCTRL(*this, "ID_CLEARRECONNECT", wxCheckBox); if (pCheck->GetValue()) { bool asked = false; const std::vector<CState*> *states = CContextManager::Get()->GetAllStates(); for (std::vector<CState*>::const_iterator iter = states->begin(); iter != states->end(); ++iter) { CState* pState = *iter; if (pState->IsRemoteConnected() || !pState->IsRemoteIdle()) { if (!asked) { int res = wxMessageBox(_("Reconnect information cannot be cleared while connected to a server.\nIf you continue, your connection will be disconnected."), _("Clear private data"), wxOK | wxCANCEL); if (res != wxOK) return; asked = true; } pState->GetRecursiveOperationHandler()->StopRecursiveOperation(); if (!pState->m_pCommandQueue->Cancel()) { m_timer.SetOwner(this); m_timer.Start(250, true); } else pState->Disconnect(); } } // Doesn't harm to do it now, but has to be repeated later just to be safe ClearReconnect(); } if (pSitemanagerCheck->GetValue()) { CInterProcessMutex sitemanagerMutex(MUTEX_SITEMANAGERGLOBAL, false); while (sitemanagerMutex.TryLock() == 0) { int res = wxMessageBox(_("The Site Manager is opened in another instance of FileZilla 3.\nPlease close it or the data cannot be deleted."), _("Clear private data"), wxOK | wxCANCEL); if (res != wxYES) return; } CInterProcessMutex mutex(MUTEX_SITEMANAGER); RemoveXmlFile(_T("sitemanager")); } if (pQueueCheck->GetValue()) { m_pMainFrame->GetQueue()->SetActive(false); m_pMainFrame->GetQueue()->RemoveAll(); CInterProcessMutex mutex(MUTEX_QUEUE); RemoveXmlFile(_T("queue")); } }
BOOL DbgHelp::SymCleanup() const { Guard lock(mutex()); return mSymCleanup(mProcess); }
void unlock() { mutex().unlock(); }
PVOID DbgHelp::SymFunctionTableAccess64(DWORD64 addressBase) const { Guard lock(mutex()); return mSymFunctionTableAccess64(mProcess, addressBase); }
//---------------------------------------------------------------------------------------------------- void EERotateYXProcess(EEObject* _object, float _time, float _radiansYX, float _delay, bool _isInfinite, float _startTime) { try { float remainTime = _delay + _time; float progress = _startTime; float speed = _radiansYX / _time; while (1) { EEThreadSleep(20); std::lock_guard<std::mutex> mutex(_object->GetThreadMutex()); float currTime = (float)EECore::s_EECore->GetTotalTime(); float deltaTime = currTime - progress; progress = currTime; if (remainTime <= deltaTime + _time) { remainTime = _time; break; } else { remainTime -= deltaTime; } } while (1) { EEThreadSleep(20); std::lock_guard<std::mutex> mutex(_object->GetThreadMutex()); float currTime = (float)EECore::s_EECore->GetTotalTime(); float deltaTime = currTime - progress; progress = currTime; if (remainTime <= deltaTime && !_isInfinite) { FLOAT3 finalCenter = _object->GetFinalCenter(); MATRIX centerToOrigin = MatrixTranslation(-finalCenter.x, -finalCenter.y, 0.0f); MATRIX rotation = MatrixRotationAxisN(FLOAT3(0.0f, 0.0f, 1.0f), speed * remainTime); MATRIX originToCenter = MatrixTranslation(finalCenter.x, finalCenter.y, 0.0f); _object->SetRotation(_object->GetRotation() * centerToOrigin * rotation * originToCenter); remainTime = 0.f; return; } else { FLOAT3 finalCenter = _object->GetFinalCenter(); MATRIX centerToOrigin = MatrixTranslation(-finalCenter.x, -finalCenter.y, 0.0f); MATRIX rotation = MatrixRotationAxisN(FLOAT3(0.0f, 0.0f, 1.0f), speed * deltaTime); MATRIX originToCenter = MatrixTranslation(finalCenter.x, finalCenter.y, 0.0f); _object->SetRotation(_object->GetRotation() * centerToOrigin * rotation * originToCenter); remainTime -= deltaTime; } } } catch (boost::thread_interrupted&) { return; } }
DWORD64 DbgHelp::SymGetModuleBase64(DWORD64 address) const { Guard lock(mutex()); return mSymGetModuleBase64(mProcess, address); }
void FrameBuffer::DestroyRenderContext(HandleType p_context) { android::Mutex::Autolock mutex(m_lock); m_contexts.erase(p_context); }
BOOL DbgHelp::SymGetSymFromAddr64(DWORD64 address, PDWORD64 displacement, PIMAGEHLP_SYMBOL64 symbol) const { Guard lock(mutex()); return mSymGetSymFromAddr64(mProcess, address, displacement, symbol); }
bool FrameBuffer::bindContext(HandleType p_context, HandleType p_drawSurface, HandleType p_readSurface) { android::Mutex::Autolock mutex(m_lock); WindowSurfacePtr draw(NULL), read(NULL); RenderContextPtr ctx(NULL); // // if this is not an unbind operation - make sure all handles are good // if (p_context || p_drawSurface || p_readSurface) { RenderContextMap::iterator r( m_contexts.find(p_context) ); if (r == m_contexts.end()) { // bad context handle return false; } ctx = (*r).second; WindowSurfaceMap::iterator w( m_windows.find(p_drawSurface) ); if (w == m_windows.end()) { // bad surface handle return false; } draw = (*w).second; if (p_readSurface != p_drawSurface) { WindowSurfaceMap::iterator w( m_windows.find(p_readSurface) ); if (w == m_windows.end()) { // bad surface handle return false; } read = (*w).second; } else { read = draw; } } if (!s_egl.eglMakeCurrent(m_eglDisplay, draw ? draw->getEGLSurface() : EGL_NO_SURFACE, read ? read->getEGLSurface() : EGL_NO_SURFACE, ctx ? ctx->getEGLContext() : EGL_NO_CONTEXT)) { // MakeCurrent failed return false; } // // Bind the surface(s) to the context // RenderThreadInfo *tinfo = getRenderThreadInfo(); if (draw.Ptr() == NULL && read.Ptr() == NULL) { // if this is an unbind operation - make sure the current bound // surfaces get unbound from the context. draw = tinfo->currDrawSurf; read = tinfo->currReadSurf; } if (draw.Ptr() != NULL && read.Ptr() != NULL) { if (p_readSurface != p_drawSurface) { draw->bind( ctx, SURFACE_BIND_DRAW ); read->bind( ctx, SURFACE_BIND_READ ); } else { draw->bind( ctx, SURFACE_BIND_READDRAW ); } } // // update thread info with current bound context // tinfo->currContext = ctx; tinfo->currDrawSurf = draw; tinfo->currReadSurf = read; if (ctx) { if (ctx->isGL2()) tinfo->m_gl2Dec.setContextData(&ctx->decoderContextData()); else tinfo->m_glDec.setContextData(&ctx->decoderContextData()); } else { tinfo->m_glDec.setContextData(NULL); tinfo->m_gl2Dec.setContextData(NULL); } return true; }
void Node::_addConnectionDescription( ConnectionDescriptionPtr cd ) { lunchbox::ScopedFastWrite mutex( _impl->connectionDescriptions ); _impl->connectionDescriptions->push_back( cd ); }