mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-12 06:39:14 +01:00
Make DolphinAnalytics a true singleton - static local variables are initialized in a thread safe manner since C++11
Also works around a Visual Studio 2017 bug where static inline class fields are destructed multiple times
This commit is contained in:
parent
5262f39026
commit
6c21811090
@ -639,7 +639,7 @@ static void Run(JNIEnv* env, const std::vector<std::string>& paths, bool first_o
|
|||||||
|
|
||||||
if (first_open)
|
if (first_open)
|
||||||
{
|
{
|
||||||
DolphinAnalytics::Instance()->ReportDolphinStart(GetAnalyticValue("DEVICE_TYPE"));
|
DolphinAnalytics::Instance().ReportDolphinStart(GetAnalyticValue("DEVICE_TYPE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
WiimoteReal::InitAdapterClass();
|
WiimoteReal::InitAdapterClass();
|
||||||
|
@ -53,14 +53,10 @@ DolphinAnalytics::DolphinAnalytics()
|
|||||||
MakeBaseBuilder();
|
MakeBaseBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<DolphinAnalytics> DolphinAnalytics::Instance()
|
DolphinAnalytics& DolphinAnalytics::Instance()
|
||||||
{
|
{
|
||||||
std::lock_guard lk{s_instance_mutex};
|
static DolphinAnalytics instance;
|
||||||
if (!s_instance)
|
return instance;
|
||||||
{
|
|
||||||
s_instance.reset(new DolphinAnalytics());
|
|
||||||
}
|
|
||||||
return s_instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinAnalytics::ReloadConfig()
|
void DolphinAnalytics::ReloadConfig()
|
||||||
|
@ -36,7 +36,7 @@ class DolphinAnalytics
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Performs lazy-initialization of a singleton and returns the instance.
|
// Performs lazy-initialization of a singleton and returns the instance.
|
||||||
static std::shared_ptr<DolphinAnalytics> Instance();
|
static DolphinAnalytics& Instance();
|
||||||
|
|
||||||
#if defined(ANDROID)
|
#if defined(ANDROID)
|
||||||
// Get value from java.
|
// Get value from java.
|
||||||
@ -124,9 +124,4 @@ private:
|
|||||||
|
|
||||||
std::mutex m_reporter_mutex;
|
std::mutex m_reporter_mutex;
|
||||||
Common::AnalyticsReporter m_reporter;
|
Common::AnalyticsReporter m_reporter;
|
||||||
|
|
||||||
// Shared pointer in order to allow for multithreaded use of the instance and
|
|
||||||
// avoid races at reinitialization time.
|
|
||||||
static inline std::mutex s_instance_mutex;
|
|
||||||
static inline std::shared_ptr<DolphinAnalytics> s_instance;
|
|
||||||
};
|
};
|
||||||
|
@ -745,7 +745,7 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri
|
|||||||
HLE::Reload();
|
HLE::Reload();
|
||||||
PatchEngine::Reload();
|
PatchEngine::Reload();
|
||||||
HiresTexture::Update();
|
HiresTexture::Update();
|
||||||
DolphinAnalytics::Instance()->ReportGameStart();
|
DolphinAnalytics::Instance().ReportGameStart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ static void CpuThread(const std::optional<std::string>& savestate_path, bool del
|
|||||||
Common::SetCurrentThreadName("CPU-GPU thread");
|
Common::SetCurrentThreadName("CPU-GPU thread");
|
||||||
|
|
||||||
// This needs to be delayed until after the video backend is ready.
|
// This needs to be delayed until after the video backend is ready.
|
||||||
DolphinAnalytics::Instance()->ReportGameStart();
|
DolphinAnalytics::Instance().ReportGameStart();
|
||||||
|
|
||||||
if (_CoreParameter.bFastmem)
|
if (_CoreParameter.bFastmem)
|
||||||
EMM::InstallExceptionHandler(); // Let's run under memory watch
|
EMM::InstallExceptionHandler(); // Let's run under memory watch
|
||||||
|
@ -520,7 +520,7 @@ bool Wiimote::ProcessReadDataRequest()
|
|||||||
m_read_request.address + m_read_request.size > CameraLogic::REPORT_DATA_OFFSET;
|
m_read_request.address + m_read_request.size > CameraLogic::REPORT_DATA_OFFSET;
|
||||||
|
|
||||||
if (is_reading_ext || is_reading_ir)
|
if (is_reading_ext || is_reading_ir)
|
||||||
DolphinAnalytics::Instance()->ReportGameQuirk(GameQuirk::DIRECTLY_READS_WIIMOTE_INPUT);
|
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::DIRECTLY_READS_WIIMOTE_INPUT);
|
||||||
|
|
||||||
// Top byte of address is ignored on the bus, but it IS maintained in the read-reply.
|
// Top byte of address is ignored on the bus, but it IS maintained in the read-reply.
|
||||||
auto const bytes_read = m_i2c_bus.BusRead(
|
auto const bytes_read = m_i2c_bus.BusRead(
|
||||||
|
@ -154,7 +154,7 @@ u32 InstructionCache::ReadInstruction(u32 addr)
|
|||||||
{
|
{
|
||||||
INFO_LOG(POWERPC, "ICache read at %08x returned stale data: CACHED: %08x vs. RAM: %08x", addr,
|
INFO_LOG(POWERPC, "ICache read at %08x returned stale data: CACHED: %08x vs. RAM: %08x", addr,
|
||||||
res, inmem);
|
res, inmem);
|
||||||
DolphinAnalytics::Instance()->ReportGameQuirk(GameQuirk::ICACHE_MATTERS);
|
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::ICACHE_MATTERS);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ int main(int argc, char* argv[])
|
|||||||
sigaction(SIGINT, &sa, nullptr);
|
sigaction(SIGINT, &sa, nullptr);
|
||||||
sigaction(SIGTERM, &sa, nullptr);
|
sigaction(SIGTERM, &sa, nullptr);
|
||||||
|
|
||||||
DolphinAnalytics::Instance()->ReportDolphinStart("nogui");
|
DolphinAnalytics::Instance().ReportDolphinStart("nogui");
|
||||||
|
|
||||||
if (!BootManager::BootCore(std::move(boot), s_platform->GetWindowSystemInfo()))
|
if (!BootManager::BootCore(std::move(boot), s_platform->GetWindowSystemInfo()))
|
||||||
{
|
{
|
||||||
|
@ -177,7 +177,7 @@ int main(int argc, char* argv[])
|
|||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
{
|
{
|
||||||
DolphinAnalytics::Instance()->ReportDolphinStart("qt");
|
DolphinAnalytics::Instance().ReportDolphinStart("qt");
|
||||||
|
|
||||||
MainWindow win{std::move(boot), static_cast<const char*>(options.get("movie"))};
|
MainWindow win{std::move(boot), static_cast<const char*>(options.get("movie"))};
|
||||||
if (options.is_set("debugger"))
|
if (options.is_set("debugger"))
|
||||||
@ -210,7 +210,7 @@ int main(int argc, char* argv[])
|
|||||||
SConfig::GetInstance().m_analytics_permission_asked = true;
|
SConfig::GetInstance().m_analytics_permission_asked = true;
|
||||||
Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes);
|
Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes);
|
||||||
|
|
||||||
DolphinAnalytics::Instance()->ReloadConfig();
|
DolphinAnalytics::Instance().ReloadConfig();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ void GeneralPane::OnSaveConfig()
|
|||||||
|
|
||||||
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
||||||
Settings::Instance().SetAnalyticsEnabled(m_checkbox_enable_analytics->isChecked());
|
Settings::Instance().SetAnalyticsEnabled(m_checkbox_enable_analytics->isChecked());
|
||||||
DolphinAnalytics::Instance()->ReloadConfig();
|
DolphinAnalytics::Instance().ReloadConfig();
|
||||||
#endif
|
#endif
|
||||||
settings.bCPUThread = m_checkbox_dualcore->isChecked();
|
settings.bCPUThread = m_checkbox_dualcore->isChecked();
|
||||||
Config::SetBaseOrCurrent(Config::MAIN_CPU_THREAD, m_checkbox_dualcore->isChecked());
|
Config::SetBaseOrCurrent(Config::MAIN_CPU_THREAD, m_checkbox_dualcore->isChecked());
|
||||||
@ -325,8 +325,8 @@ void GeneralPane::OnSaveConfig()
|
|||||||
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
||||||
void GeneralPane::GenerateNewIdentity()
|
void GeneralPane::GenerateNewIdentity()
|
||||||
{
|
{
|
||||||
DolphinAnalytics::Instance()->GenerateNewIdentity();
|
DolphinAnalytics::Instance().GenerateNewIdentity();
|
||||||
DolphinAnalytics::Instance()->ReloadConfig();
|
DolphinAnalytics::Instance().ReloadConfig();
|
||||||
ModalMessageBox message_box(this);
|
ModalMessageBox message_box(this);
|
||||||
message_box.setIcon(QMessageBox::Information);
|
message_box.setIcon(QMessageBox::Information);
|
||||||
message_box.setWindowTitle(tr("Identity Generation"));
|
message_box.setWindowTitle(tr("Identity Generation"));
|
||||||
|
@ -1282,7 +1282,7 @@ void Renderer::Swap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u6
|
|||||||
perf_sample.speed_ratio = SystemTimers::GetEstimatedEmulationPerformance();
|
perf_sample.speed_ratio = SystemTimers::GetEstimatedEmulationPerformance();
|
||||||
perf_sample.num_prims = stats.thisFrame.numPrims + stats.thisFrame.numDLPrims;
|
perf_sample.num_prims = stats.thisFrame.numPrims + stats.thisFrame.numDLPrims;
|
||||||
perf_sample.num_draw_calls = stats.thisFrame.numDrawCalls;
|
perf_sample.num_draw_calls = stats.thisFrame.numDrawCalls;
|
||||||
DolphinAnalytics::Instance()->ReportPerformanceInfo(std::move(perf_sample));
|
DolphinAnalytics::Instance().ReportPerformanceInfo(std::move(perf_sample));
|
||||||
|
|
||||||
if (IsFrameDumping())
|
if (IsFrameDumping())
|
||||||
DumpCurrentFrame(xfb_entry->texture.get(), xfb_rect, ticks);
|
DumpCurrentFrame(xfb_entry->texture.get(), xfb_rect, ticks);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user