Merge pull request #2283 from RyeMutt/reduce-thread-contention
Reduce thread contention between main thread and asset fetch threadsmaster
commit
a52ba692a1
|
|
@ -489,6 +489,7 @@ HttpStatus HttpRequest::createService()
|
|||
HttpRequestQueue::init();
|
||||
HttpRequestQueue * rq = HttpRequestQueue::instanceOf();
|
||||
HttpService::init(rq);
|
||||
HTTPStats::createInstance();
|
||||
has_inited = true;
|
||||
}
|
||||
|
||||
|
|
@ -502,6 +503,7 @@ HttpStatus HttpRequest::destroyService()
|
|||
|
||||
if (has_inited)
|
||||
{
|
||||
HTTPStats::deleteSingleton();
|
||||
HttpService::term();
|
||||
HttpRequestQueue::term();
|
||||
has_inited = false;
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@
|
|||
|
||||
namespace LLCore
|
||||
{
|
||||
class HTTPStats : public LLSingleton<HTTPStats>
|
||||
class HTTPStats final : public LLSimpleton<HTTPStats>
|
||||
{
|
||||
LLSINGLETON(HTTPStats);
|
||||
virtual ~HTTPStats();
|
||||
|
||||
public:
|
||||
HTTPStats();
|
||||
~HTTPStats();
|
||||
|
||||
void resetStats();
|
||||
|
||||
typedef LLStatsAccumulator StatsAccumulator;
|
||||
|
|
|
|||
|
|
@ -39,15 +39,25 @@
|
|||
|
||||
#include "lldiskcache.h"
|
||||
|
||||
/**
|
||||
* The prefix inserted at the start of a cache file filename to
|
||||
* help identify it as a cache file. It's probably not required
|
||||
* (just the presence in the cache folder is enough) but I am
|
||||
* paranoid about the cache folder being set to something bad
|
||||
* like the users' OS system dir by mistake or maliciously and
|
||||
* this will help to offset any damage if that happens.
|
||||
*/
|
||||
static const std::string CACHE_FILENAME_PREFIX("sl_cache");
|
||||
|
||||
std::string LLDiskCache::sCacheDir;
|
||||
|
||||
LLDiskCache::LLDiskCache(const std::string cache_dir,
|
||||
const uintmax_t max_size_bytes,
|
||||
const bool enable_cache_debug_info) :
|
||||
mCacheDir(cache_dir),
|
||||
mMaxSizeBytes(max_size_bytes),
|
||||
mEnableCacheDebugInfo(enable_cache_debug_info)
|
||||
{
|
||||
mCacheFilenamePrefix = "sl_cache";
|
||||
|
||||
sCacheDir = cache_dir;
|
||||
LLFile::mkdir(cache_dir);
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +93,7 @@ void LLDiskCache::purge()
|
|||
{
|
||||
if (mEnableCacheDebugInfo)
|
||||
{
|
||||
LL_INFOS() << "Total dir size before purge is " << dirFileSize(mCacheDir) << LL_ENDL;
|
||||
LL_INFOS() << "Total dir size before purge is " << dirFileSize(sCacheDir) << LL_ENDL;
|
||||
}
|
||||
|
||||
boost::system::error_code ec;
|
||||
|
|
@ -93,9 +103,9 @@ void LLDiskCache::purge()
|
|||
std::vector<file_info_t> file_info;
|
||||
|
||||
#if LL_WINDOWS
|
||||
std::wstring cache_path(utf8str_to_utf16str(mCacheDir));
|
||||
std::wstring cache_path(utf8str_to_utf16str(sCacheDir));
|
||||
#else
|
||||
std::string cache_path(mCacheDir);
|
||||
std::string cache_path(sCacheDir);
|
||||
#endif
|
||||
if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed())
|
||||
{
|
||||
|
|
@ -104,7 +114,7 @@ void LLDiskCache::purge()
|
|||
{
|
||||
if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed())
|
||||
{
|
||||
if ((*iter).path().string().find(mCacheFilenamePrefix) != std::string::npos)
|
||||
if ((*iter).path().string().find(CACHE_FILENAME_PREFIX) != std::string::npos)
|
||||
{
|
||||
uintmax_t file_size = boost::filesystem::file_size(*iter, ec);
|
||||
if (ec.failed())
|
||||
|
|
@ -181,7 +191,7 @@ void LLDiskCache::purge()
|
|||
LL_INFOS() << line.str() << LL_ENDL;
|
||||
}
|
||||
|
||||
LL_INFOS() << "Total dir size after purge is " << dirFileSize(mCacheDir) << LL_ENDL;
|
||||
LL_INFOS() << "Total dir size after purge is " << dirFileSize(sCacheDir) << LL_ENDL;
|
||||
LL_INFOS() << "Cache purge took " << execute_time << " ms to execute for " << file_info.size() << " files" << LL_ENDL;
|
||||
}
|
||||
}
|
||||
|
|
@ -236,89 +246,9 @@ const std::string LLDiskCache::assetTypeToString(LLAssetType::EType at)
|
|||
return std::string("UNKNOWN");
|
||||
}
|
||||
|
||||
const std::string LLDiskCache::metaDataToFilepath(const std::string id,
|
||||
LLAssetType::EType at,
|
||||
const std::string extra_info)
|
||||
const std::string LLDiskCache::metaDataToFilepath(const std::string& id, LLAssetType::EType at)
|
||||
{
|
||||
std::ostringstream file_path;
|
||||
|
||||
file_path << mCacheDir;
|
||||
file_path << gDirUtilp->getDirDelimiter();
|
||||
file_path << mCacheFilenamePrefix;
|
||||
file_path << "_";
|
||||
file_path << id;
|
||||
file_path << "_";
|
||||
file_path << (extra_info.empty() ? "0" : extra_info);
|
||||
//file_path << "_";
|
||||
//file_path << assetTypeToString(at); // see SL-14210 Prune descriptive tag from new cache filenames
|
||||
// for details of why it was removed. Note that if you put it
|
||||
// back or change the format of the filename, the cache files
|
||||
// files will be invalidated (and perhaps, more importantly,
|
||||
// never deleted unless you delete them manually).
|
||||
file_path << ".asset";
|
||||
|
||||
return file_path.str();
|
||||
}
|
||||
|
||||
void LLDiskCache::updateFileAccessTime(const std::string file_path)
|
||||
{
|
||||
/**
|
||||
* Threshold in time_t units that is used to decide if the last access time
|
||||
* time of the file is updated or not. Added as a precaution for the concern
|
||||
* outlined in SL-14582 about frequent writes on older SSDs reducing their
|
||||
* lifespan. I think this is the right place for the threshold value - rather
|
||||
* than it being a pref - do comment on that Jira if you disagree...
|
||||
*
|
||||
* Let's start with 1 hour in time_t units and see how that unfolds
|
||||
*/
|
||||
const std::time_t time_threshold = 1 * 60 * 60;
|
||||
|
||||
// current time
|
||||
const std::time_t cur_time = std::time(nullptr);
|
||||
|
||||
boost::system::error_code ec;
|
||||
#if LL_WINDOWS
|
||||
// file last write time
|
||||
const std::time_t last_write_time = boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), ec);
|
||||
if (ec.failed())
|
||||
{
|
||||
LL_WARNS() << "Failed to read last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
|
||||
// delta between cur time and last time the file was written
|
||||
const std::time_t delta_time = cur_time - last_write_time;
|
||||
|
||||
// we only write the new value if the time in time_threshold has elapsed
|
||||
// before the last one
|
||||
if (delta_time > time_threshold)
|
||||
{
|
||||
boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), cur_time, ec);
|
||||
}
|
||||
#else
|
||||
// file last write time
|
||||
const std::time_t last_write_time = boost::filesystem::last_write_time(file_path, ec);
|
||||
if (ec.failed())
|
||||
{
|
||||
LL_WARNS() << "Failed to read last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
|
||||
// delta between cur time and last time the file was written
|
||||
const std::time_t delta_time = cur_time - last_write_time;
|
||||
|
||||
// we only write the new value if the time in time_threshold has elapsed
|
||||
// before the last one
|
||||
if (delta_time > time_threshold)
|
||||
{
|
||||
boost::filesystem::last_write_time(file_path, cur_time, ec);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ec.failed())
|
||||
{
|
||||
LL_WARNS() << "Failed to update last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL;
|
||||
}
|
||||
return llformat("%s%s%s_%s_0.asset", sCacheDir.c_str(), gDirUtilp->getDirDelimiter().c_str(), CACHE_FILENAME_PREFIX.c_str(), id.c_str());
|
||||
}
|
||||
|
||||
const std::string LLDiskCache::getCacheInfo()
|
||||
|
|
@ -326,7 +256,7 @@ const std::string LLDiskCache::getCacheInfo()
|
|||
std::ostringstream cache_info;
|
||||
|
||||
F32 max_in_mb = (F32)mMaxSizeBytes / (1024.0f * 1024.0f);
|
||||
F32 percent_used = ((F32)dirFileSize(mCacheDir) / (F32)mMaxSizeBytes) * 100.0f;
|
||||
F32 percent_used = ((F32)dirFileSize(sCacheDir) / (F32)mMaxSizeBytes) * 100.0f;
|
||||
|
||||
cache_info << std::fixed;
|
||||
cache_info << std::setprecision(1);
|
||||
|
|
@ -346,9 +276,9 @@ void LLDiskCache::clearCache()
|
|||
*/
|
||||
boost::system::error_code ec;
|
||||
#if LL_WINDOWS
|
||||
std::wstring cache_path(utf8str_to_utf16str(mCacheDir));
|
||||
std::wstring cache_path(utf8str_to_utf16str(sCacheDir));
|
||||
#else
|
||||
std::string cache_path(mCacheDir);
|
||||
std::string cache_path(sCacheDir);
|
||||
#endif
|
||||
if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed())
|
||||
{
|
||||
|
|
@ -357,7 +287,7 @@ void LLDiskCache::clearCache()
|
|||
{
|
||||
if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed())
|
||||
{
|
||||
if ((*iter).path().string().find(mCacheFilenamePrefix) != std::string::npos)
|
||||
if ((*iter).path().string().find(CACHE_FILENAME_PREFIX) != std::string::npos)
|
||||
{
|
||||
boost::filesystem::remove(*iter, ec);
|
||||
if (ec.failed())
|
||||
|
|
@ -431,7 +361,7 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir)
|
|||
{
|
||||
if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed())
|
||||
{
|
||||
if ((*iter).path().string().find(mCacheFilenamePrefix) != std::string::npos)
|
||||
if ((*iter).path().string().find(CACHE_FILENAME_PREFIX) != std::string::npos)
|
||||
{
|
||||
uintmax_t file_size = boost::filesystem::file_size(*iter, ec);
|
||||
if (!ec.failed())
|
||||
|
|
|
|||
|
|
@ -104,16 +104,9 @@ class LLDiskCache :
|
|||
* so many things had to be pushed back there to accomodate it, that I
|
||||
* decided to move it here. Still not sure that's completely right.
|
||||
*/
|
||||
const std::string metaDataToFilepath(const std::string id,
|
||||
LLAssetType::EType at,
|
||||
const std::string extra_info);
|
||||
static const std::string metaDataToFilepath(const std::string& id,
|
||||
LLAssetType::EType at);
|
||||
|
||||
/**
|
||||
* Update the "last write time" of a file to "now". This must be called whenever a
|
||||
* file in the cache is read (not written) so that the last time the file was
|
||||
* accessed is up to date (This is used in the mechanism for purging the cache)
|
||||
*/
|
||||
void updateFileAccessTime(const std::string file_path);
|
||||
|
||||
/**
|
||||
* Purge the oldest items in the cache so that the combined size of all files
|
||||
|
|
@ -170,17 +163,7 @@ class LLDiskCache :
|
|||
* setting could potentially point it at a non-cache directory (for example,
|
||||
* the Windows System dir) with disastrous results.
|
||||
*/
|
||||
std::string mCacheDir;
|
||||
|
||||
/**
|
||||
* The prefix inserted at the start of a cache file filename to
|
||||
* help identify it as a cache file. It's probably not required
|
||||
* (just the presence in the cache folder is enough) but I am
|
||||
* paranoid about the cache folder being set to something bad
|
||||
* like the users' OS system dir by mistake or maliciously and
|
||||
* this will help to offset any damage if that happens.
|
||||
*/
|
||||
std::string mCacheFilenamePrefix;
|
||||
static std::string sCacheDir;
|
||||
|
||||
/**
|
||||
* When enabled, displays additional debugging information in
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
#include "llfasttimer.h"
|
||||
#include "lldiskcache.h"
|
||||
|
||||
#include "boost/filesystem.hpp"
|
||||
|
||||
const S32 LLFileSystem::READ = 0x00000001;
|
||||
const S32 LLFileSystem::WRITE = 0x00000002;
|
||||
const S32 LLFileSystem::READ_WRITE = 0x00000003; // LLFileSystem::READ & LLFileSystem::WRITE
|
||||
|
|
@ -56,9 +58,8 @@ LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_
|
|||
{
|
||||
// build the filename (TODO: we do this in a few places - perhaps we should factor into a single function)
|
||||
std::string id;
|
||||
mFileID.toString(id);
|
||||
const std::string extra_info = "";
|
||||
const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id, mFileType, extra_info);
|
||||
mFileID.asString();
|
||||
const std::string filename = LLDiskCache::metaDataToFilepath(id, mFileType);
|
||||
|
||||
// update the last access time for the file if it exists - this is required
|
||||
// even though we are reading and not writing because this is the
|
||||
|
|
@ -67,7 +68,7 @@ LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_
|
|||
bool exists = gDirUtilp->fileExists(filename);
|
||||
if (exists)
|
||||
{
|
||||
LLDiskCache::getInstance()->updateFileAccessTime(filename);
|
||||
updateFileAccessTime(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -82,8 +83,7 @@ bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType fil
|
|||
LL_PROFILE_ZONE_SCOPED;
|
||||
std::string id_str;
|
||||
file_id.toString(id_str);
|
||||
const std::string extra_info = "";
|
||||
const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id_str, file_type, extra_info);
|
||||
const std::string filename = LLDiskCache::metaDataToFilepath(id_str, file_type);
|
||||
|
||||
llifstream file(filename, std::ios::binary);
|
||||
if (file.is_open())
|
||||
|
|
@ -99,8 +99,7 @@ bool LLFileSystem::removeFile(const LLUUID& file_id, const LLAssetType::EType fi
|
|||
{
|
||||
std::string id_str;
|
||||
file_id.toString(id_str);
|
||||
const std::string extra_info = "";
|
||||
const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id_str, file_type, extra_info);
|
||||
const std::string filename = LLDiskCache::metaDataToFilepath(id_str, file_type);
|
||||
|
||||
LLFile::remove(filename.c_str(), suppress_error);
|
||||
|
||||
|
|
@ -113,12 +112,11 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp
|
|||
{
|
||||
std::string old_id_str;
|
||||
old_file_id.toString(old_id_str);
|
||||
const std::string extra_info = "";
|
||||
const std::string old_filename = LLDiskCache::getInstance()->metaDataToFilepath(old_id_str, old_file_type, extra_info);
|
||||
const std::string old_filename = LLDiskCache::metaDataToFilepath(old_id_str, old_file_type);
|
||||
|
||||
std::string new_id_str;
|
||||
new_file_id.toString(new_id_str);
|
||||
const std::string new_filename = LLDiskCache::getInstance()->metaDataToFilepath(new_id_str, new_file_type, extra_info);
|
||||
const std::string new_filename = LLDiskCache::metaDataToFilepath(new_id_str, new_file_type);
|
||||
|
||||
// Rename needs the new file to not exist.
|
||||
LLFileSystem::removeFile(new_file_id, new_file_type, ENOENT);
|
||||
|
|
@ -140,8 +138,7 @@ S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType fi
|
|||
{
|
||||
std::string id_str;
|
||||
file_id.toString(id_str);
|
||||
const std::string extra_info = "";
|
||||
const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id_str, file_type, extra_info);
|
||||
const std::string filename = LLDiskCache::metaDataToFilepath(id_str, file_type);
|
||||
|
||||
S32 file_size = 0;
|
||||
llifstream file(filename, std::ios::binary);
|
||||
|
|
@ -160,8 +157,7 @@ bool LLFileSystem::read(U8* buffer, S32 bytes)
|
|||
|
||||
std::string id;
|
||||
mFileID.toString(id);
|
||||
const std::string extra_info = "";
|
||||
const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id, mFileType, extra_info);
|
||||
const std::string filename = LLDiskCache::metaDataToFilepath(id, mFileType);
|
||||
|
||||
llifstream file(filename, std::ios::binary);
|
||||
if (file.is_open())
|
||||
|
|
@ -205,8 +201,7 @@ bool LLFileSystem::write(const U8* buffer, S32 bytes)
|
|||
{
|
||||
std::string id_str;
|
||||
mFileID.toString(id_str);
|
||||
const std::string extra_info = "";
|
||||
const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id_str, mFileType, extra_info);
|
||||
const std::string filename = LLDiskCache::metaDataToFilepath(id_str, mFileType);
|
||||
|
||||
bool success = false;
|
||||
|
||||
|
|
@ -325,3 +320,64 @@ bool LLFileSystem::remove()
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LLFileSystem::updateFileAccessTime(const std::string& file_path)
|
||||
{
|
||||
/**
|
||||
* Threshold in time_t units that is used to decide if the last access time
|
||||
* time of the file is updated or not. Added as a precaution for the concern
|
||||
* outlined in SL-14582 about frequent writes on older SSDs reducing their
|
||||
* lifespan. I think this is the right place for the threshold value - rather
|
||||
* than it being a pref - do comment on that Jira if you disagree...
|
||||
*
|
||||
* Let's start with 1 hour in time_t units and see how that unfolds
|
||||
*/
|
||||
const std::time_t time_threshold = 1 * 60 * 60;
|
||||
|
||||
// current time
|
||||
const std::time_t cur_time = std::time(nullptr);
|
||||
|
||||
boost::system::error_code ec;
|
||||
#if LL_WINDOWS
|
||||
// file last write time
|
||||
const std::time_t last_write_time = boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), ec);
|
||||
if (ec.failed())
|
||||
{
|
||||
LL_WARNS() << "Failed to read last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
|
||||
// delta between cur time and last time the file was written
|
||||
const std::time_t delta_time = cur_time - last_write_time;
|
||||
|
||||
// we only write the new value if the time in time_threshold has elapsed
|
||||
// before the last one
|
||||
if (delta_time > time_threshold)
|
||||
{
|
||||
boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), cur_time, ec);
|
||||
}
|
||||
#else
|
||||
// file last write time
|
||||
const std::time_t last_write_time = boost::filesystem::last_write_time(file_path, ec);
|
||||
if (ec.failed())
|
||||
{
|
||||
LL_WARNS() << "Failed to read last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
|
||||
// delta between cur time and last time the file was written
|
||||
const std::time_t delta_time = cur_time - last_write_time;
|
||||
|
||||
// we only write the new value if the time in time_threshold has elapsed
|
||||
// before the last one
|
||||
if (delta_time > time_threshold)
|
||||
{
|
||||
boost::filesystem::last_write_time(file_path, cur_time, ec);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ec.failed())
|
||||
{
|
||||
LL_WARNS() << "Failed to update last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,13 @@ class LLFileSystem
|
|||
bool rename(const LLUUID& new_id, const LLAssetType::EType new_type);
|
||||
bool remove();
|
||||
|
||||
/**
|
||||
* Update the "last write time" of a file to "now". This must be called whenever a
|
||||
* file in the cache is read (not written) so that the last time the file was
|
||||
* accessed is up to date (This is used in the mechanism for purging the cache)
|
||||
*/
|
||||
void updateFileAccessTime(const std::string& file_path);
|
||||
|
||||
static bool getExists(const LLUUID& file_id, const LLAssetType::EType file_type);
|
||||
static bool removeFile(const LLUUID& file_id, const LLAssetType::EType file_type, int suppress_error = 0);
|
||||
static bool renameFile(const LLUUID& old_file_id, const LLAssetType::EType old_file_type,
|
||||
|
|
|
|||
|
|
@ -42,19 +42,13 @@ static const std::string DICT_FILE_USER = "user_dictionaries.xml";
|
|||
LLSpellChecker::settings_change_signal_t LLSpellChecker::sSettingsChangeSignal;
|
||||
|
||||
LLSpellChecker::LLSpellChecker()
|
||||
: mHunspell(NULL)
|
||||
{
|
||||
// Load initial dictionary information
|
||||
refreshDictionaryMap();
|
||||
}
|
||||
|
||||
LLSpellChecker::~LLSpellChecker()
|
||||
{
|
||||
delete mHunspell;
|
||||
}
|
||||
|
||||
void LLSpellChecker::initSingleton()
|
||||
{
|
||||
// Load initial dictionary information
|
||||
refreshDictionaryMap();
|
||||
}
|
||||
|
||||
bool LLSpellChecker::checkSpelling(const std::string& word) const
|
||||
|
|
@ -300,8 +294,7 @@ void LLSpellChecker::initHunspell(const std::string& dict_language)
|
|||
{
|
||||
if (mHunspell)
|
||||
{
|
||||
delete mHunspell;
|
||||
mHunspell = NULL;
|
||||
mHunspell.reset();
|
||||
mDictLanguage.clear();
|
||||
mDictFile.clear();
|
||||
mIgnoreList.clear();
|
||||
|
|
@ -322,11 +315,11 @@ void LLSpellChecker::initHunspell(const std::string& dict_language)
|
|||
const std::string filename_dic = dict_entry["name"].asString() + ".dic";
|
||||
if ( (gDirUtilp->fileExists(user_path + filename_aff)) && (gDirUtilp->fileExists(user_path + filename_dic)) )
|
||||
{
|
||||
mHunspell = new Hunspell((user_path + filename_aff).c_str(), (user_path + filename_dic).c_str());
|
||||
mHunspell = std::make_unique<Hunspell>((user_path + filename_aff).c_str(), (user_path + filename_dic).c_str());
|
||||
}
|
||||
else if ( (gDirUtilp->fileExists(app_path + filename_aff)) && (gDirUtilp->fileExists(app_path + filename_dic)) )
|
||||
{
|
||||
mHunspell = new Hunspell((app_path + filename_aff).c_str(), (app_path + filename_dic).c_str());
|
||||
mHunspell = std::make_unique<Hunspell>((app_path + filename_aff).c_str(), (app_path + filename_dic).c_str());
|
||||
}
|
||||
if (!mHunspell)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,12 +34,12 @@
|
|||
|
||||
class Hunspell;
|
||||
|
||||
class LLSpellChecker : public LLSingleton<LLSpellChecker>
|
||||
class LLSpellChecker : public LLSimpleton<LLSpellChecker>
|
||||
{
|
||||
LLSINGLETON(LLSpellChecker);
|
||||
public:
|
||||
LLSpellChecker();
|
||||
~LLSpellChecker();
|
||||
|
||||
public:
|
||||
void addToCustomDictionary(const std::string& word);
|
||||
void addToIgnoreList(const std::string& word);
|
||||
bool checkSpelling(const std::string& word) const;
|
||||
|
|
@ -47,7 +47,6 @@ public:
|
|||
protected:
|
||||
void addToDictFile(const std::string& dict_path, const std::string& word);
|
||||
void initHunspell(const std::string& dict_language);
|
||||
void initSingleton() override;
|
||||
|
||||
public:
|
||||
typedef std::list<std::string> dict_list_t;
|
||||
|
|
@ -77,7 +76,7 @@ public:
|
|||
static boost::signals2::connection setSettingsChangeCallback(const settings_change_signal_t::slot_type& cb);
|
||||
|
||||
protected:
|
||||
Hunspell* mHunspell;
|
||||
std::unique_ptr<Hunspell> mHunspell;
|
||||
std::string mDictLanguage;
|
||||
std::string mDictFile;
|
||||
dict_list_t mDictSecondary;
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@
|
|||
#include "llmenubutton.h"
|
||||
#include "llloadingindicator.h"
|
||||
#include "llwindow.h"
|
||||
#include "llspellcheck.h"
|
||||
|
||||
// for registration
|
||||
#include "llfiltereditor.h"
|
||||
|
|
@ -157,6 +158,7 @@ mRootView(NULL),
|
|||
mHelpImpl(NULL)
|
||||
{
|
||||
LLRender2D::createInstance(image_provider);
|
||||
LLSpellChecker::createInstance();
|
||||
|
||||
if ((get_ptr_in_map(mSettingGroups, std::string("config")) == NULL) ||
|
||||
(get_ptr_in_map(mSettingGroups, std::string("floater")) == NULL) ||
|
||||
|
|
@ -198,6 +200,7 @@ mHelpImpl(NULL)
|
|||
|
||||
LLUI::~LLUI()
|
||||
{
|
||||
LLSpellChecker::deleteSingleton();
|
||||
LLRender2D::deleteSingleton();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -801,6 +801,20 @@ bool LLAppViewer::init()
|
|||
LLUIImageList::getInstance(),
|
||||
ui_audio_callback,
|
||||
deferred_ui_audio_callback);
|
||||
|
||||
if (gSavedSettings.getBOOL("SpellCheck"))
|
||||
{
|
||||
std::list<std::string> dict_list;
|
||||
std::string dict_setting = gSavedSettings.getString("SpellCheckDictionary");
|
||||
boost::split(dict_list, dict_setting, boost::is_any_of(std::string(",")));
|
||||
if (!dict_list.empty())
|
||||
{
|
||||
LLSpellChecker::setUseSpellCheck(dict_list.front());
|
||||
dict_list.pop_front();
|
||||
LLSpellChecker::instance().setSecondaryDictionaries(dict_list);
|
||||
}
|
||||
}
|
||||
|
||||
LL_INFOS("InitInfo") << "UI initialized." << LL_ENDL ;
|
||||
|
||||
// NOW LLUI::getLanguage() should work. gDirUtilp must know the language
|
||||
|
|
@ -1265,6 +1279,7 @@ bool LLAppViewer::init()
|
|||
//LLSimpleton creations
|
||||
LLEnvironment::createInstance();
|
||||
LLWorld::createInstance();
|
||||
LLViewerStatsRecorder::createInstance();
|
||||
LLSelectMgr::createInstance();
|
||||
LLViewerCamera::createInstance();
|
||||
LL::GLTFSceneManager::createInstance();
|
||||
|
|
@ -1606,7 +1621,7 @@ bool LLAppViewer::doFrame()
|
|||
|
||||
{
|
||||
LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df gMeshRepo");
|
||||
gMeshRepo.update() ;
|
||||
gMeshRepo.update() ;
|
||||
}
|
||||
|
||||
if(!total_work_pending) //pause texture fetching threads if nothing to process.
|
||||
|
|
@ -2147,6 +2162,7 @@ bool LLAppViewer::cleanup()
|
|||
LL::GLTFSceneManager::deleteSingleton();
|
||||
LLEnvironment::deleteSingleton();
|
||||
LLSelectMgr::deleteSingleton();
|
||||
LLViewerStatsRecorder::deleteSingleton();
|
||||
LLViewerEventRecorder::deleteSingleton();
|
||||
LLWorld::deleteSingleton();
|
||||
LLVoiceClient::deleteSingleton();
|
||||
|
|
@ -2794,19 +2810,6 @@ bool LLAppViewer::initConfiguration()
|
|||
gSavedSettings.getString("Language"));
|
||||
}
|
||||
|
||||
if (gSavedSettings.getBOOL("SpellCheck"))
|
||||
{
|
||||
std::list<std::string> dict_list;
|
||||
std::string dict_setting = gSavedSettings.getString("SpellCheckDictionary");
|
||||
boost::split(dict_list, dict_setting, boost::is_any_of(std::string(",")));
|
||||
if (!dict_list.empty())
|
||||
{
|
||||
LLSpellChecker::setUseSpellCheck(dict_list.front());
|
||||
dict_list.pop_front();
|
||||
LLSpellChecker::instance().setSecondaryDictionaries(dict_list);
|
||||
}
|
||||
}
|
||||
|
||||
if (gNonInteractive)
|
||||
{
|
||||
tempSetControl("AllowMultipleViewers", "true");
|
||||
|
|
|
|||
|
|
@ -1285,7 +1285,6 @@ bool idle_startup()
|
|||
//
|
||||
// Initialize classes w/graphics stuff.
|
||||
//
|
||||
LLViewerStatsRecorder::instance(); // Since textures work in threads
|
||||
LLSurface::initClasses();
|
||||
display_startup();
|
||||
|
||||
|
|
|
|||
|
|
@ -27,16 +27,13 @@
|
|||
#include "llviewerprecompiledheaders.h"
|
||||
#include "llviewerstatsrecorder.h"
|
||||
|
||||
|
||||
#include "llcontrol.h"
|
||||
#include "llfile.h"
|
||||
#include "llviewercontrol.h"
|
||||
#include "llviewerregion.h"
|
||||
#include "llviewerobject.h"
|
||||
#include "llworld.h"
|
||||
|
||||
extern LLControlGroup gSavedSettings;
|
||||
|
||||
LLViewerStatsRecorder* LLViewerStatsRecorder::sInstance = NULL;
|
||||
LLViewerStatsRecorder::LLViewerStatsRecorder() :
|
||||
mStatsFile(NULL),
|
||||
mTimer(),
|
||||
|
|
@ -48,11 +45,6 @@ LLViewerStatsRecorder::LLViewerStatsRecorder() :
|
|||
mMaxDuration(300.f),
|
||||
mSkipSaveIfZeros(false)
|
||||
{
|
||||
if (NULL != sInstance)
|
||||
{
|
||||
LL_ERRS() << "Attempted to create multiple instances of LLViewerStatsRecorder!" << LL_ENDL;
|
||||
}
|
||||
sInstance = this;
|
||||
clearStats();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,13 +38,12 @@
|
|||
class LLMutex;
|
||||
class LLViewerObject;
|
||||
|
||||
class LLViewerStatsRecorder : public LLSingleton<LLViewerStatsRecorder>
|
||||
class LLViewerStatsRecorder : public LLSimpleton<LLViewerStatsRecorder>
|
||||
{
|
||||
LLSINGLETON(LLViewerStatsRecorder);
|
||||
public:
|
||||
LLViewerStatsRecorder();
|
||||
LOG_CLASS(LLViewerStatsRecorder);
|
||||
~LLViewerStatsRecorder();
|
||||
|
||||
public:
|
||||
// Enable/disable stats recording. This is broken down into two
|
||||
// flags so we can record stats without writing them to the log
|
||||
// file. This is useful to analyzing updates for scene loading.
|
||||
|
|
@ -140,8 +139,6 @@ private:
|
|||
void closeStatsFile();
|
||||
void makeStatsFileName();
|
||||
|
||||
static LLViewerStatsRecorder* sInstance;
|
||||
|
||||
LLFILE * mStatsFile; // File to write data into
|
||||
std::string mStatsFileName;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue