void WorkItemQueue::Process() { while (!m_dying) { WorkItem* item = NULL; boost::unique_lock<boost::mutex> lock(m_mutex); while ((!m_dying) && (item = Pop())) { try { // LslDebug( "running WorkItem %p, prio = %d", item, item->m_priority ); item->Run(); } catch (std::exception& e) { // better eat all exceptions thrown by WorkItem::Run(), // don't want to let the thread die on a single faulty WorkItem. LslDebug("WorkerThread caught exception thrown by WorkItem::Run -- %s", e.what()); } catch (...) { LslDebug("WorkerThread caught exception thrown by WorkItem::Run"); } CleanupWorkItem(item); } // cleanup leftover WorkItems while ((item = Pop()) != NULL) { CleanupWorkItem(item); } if (!m_dying) //wait for the next Push m_cond.wait(lock); } }
bool Unitsync::LoadUnitSyncLib(const std::string& unitsyncloc) { LOCK_UNITSYNC; ClearCache(); const bool ret = susynclib().Load(unitsyncloc); if (!ret) { return false; } const std::string datadir = LSL::Util::config().GetDataDir(); const std::string curdatadir = susynclib().GetSpringDataDir(); if (datadir != curdatadir) { LslWarning("Reloading unitsync due to datadir change: %s -> %s", curdatadir.c_str(), datadir.c_str()); SetSpringDataPath(datadir); susynclib().Load(unitsyncloc); } supportsManualUnLoad = LSL::susynclib().GetSpringConfigInt("UnitsyncAutoUnLoadMapsIsSupported", 0) != 0; if (supportsManualUnLoad) { LslDebug("Unitsync supports manual loading of archives (faster, yey!)"); LSL::usync().SetSpringConfigInt("UnitsyncAutoUnLoadMaps", 1); } else { LslDebug("Unitsync doesn't support manual loading of archives :-/"); } m_cache_path = LSL::Util::config().GetCachePath(); PopulateArchiveList(); return true; }
bool WorkItem::Cancel() { LslDebug("cancelling WorkItem %p", this); if (m_queue == NULL) return false; return m_queue->Remove(this); }
void WorkItemQueue::CleanupWorkItem(WorkItem* item) { if (item->m_toBeDeleted) { try { delete item; item = NULL; } catch (std::exception& e) { // idem, eat exceptions from destructor LslDebug("WorkerThread caught exception thrown by WorkItem::~WorkItem -- %s", e.what()); } } }
void GlobalsManager::DestroyAll() { for (std::vector<IGlobalObjectHolder*>::iterator i = globals.begin(); i != globals.end(); ++i) { (*i)->Nullify(); } for (std::vector<IGlobalObjectHolder*>::iterator i = globals.begin(); i != globals.end(); ++i) { try { (*i)->Destroy(); } catch (std::runtime_error& e) { LslDebug("GlobalsManager::DestroyAll(), runtume_error '%s' when destroying", e.what()); } } globals.clear(); de_initialized = true; }
std::map<std::string, SpringBundle> SpringBundle::GetSpringVersionList(const std::list<SpringBundle>& unitsync_paths) { std::map<std::string, SpringBundle> ret; std::map<std::string, std::string> uniq; for (SpringBundle bundle : unitsync_paths) { try { bundle.AutoComplete(); if (uniq.find(bundle.unitsync) != uniq.end()) //don't check/add the same unitsync twice continue; if (bundle.IsValid() && (ret.find(bundle.version) == ret.end())) { LslDebug("Found spring version: %s %s %s", bundle.version.c_str(), bundle.spring.c_str(), bundle.unitsync.c_str()); ret[bundle.version] = bundle; uniq[bundle.unitsync] = bundle.version; } } catch (...) { } } return ret; }
bool Spring::LaunchSpring( const std::string& params ) { if ( m_running ) { LslError( "Spring already running!" ); return false; } if ( !Util::FileExists( sett().GetCurrentUsedSpringBinary() ) ) { LslError( "spring binary not found at set location: %s", sett().GetCurrentUsedSpringBinary().c_str() ); return false; } std::string configfileflags = sett().GetCurrentUsedSpringConfigFilePath(); if ( !configfileflags.empty() ) { configfileflags = "--config=\"" + configfileflags + "\" "; } std::string cmd = "\"" + sett().GetCurrentUsedSpringBinary(); #ifdef __WXMAC__ wxChar sep = wxFileName::GetPathSeparator(); if ( sett().GetCurrentUsedSpringBinary().AfterLast('.') == "app" ) cmd += sep + std::string("Contents") + sep + std::string("MacOS") + sep + std::string("spring"); // append app bundle inner path #endif cmd += "\" " + configfileflags + params; LslDebug( "spring call params: %s", cmd.c_str() ); if ( m_process == 0 ) m_process = new SpringProcess( *this ); m_process->Create(); m_process->SetCommand( cmd ); m_process->Run(); m_running = true; return true; }
bool Spring::RunReplay ( const std::string& filename ) { LslDebug( "launching spring with replay: %s", filename.c_str() ); return LaunchSpring( "\"" + filename + "\""); }