aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/metrics.h
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-08-25 16:03:57 -0700
committerRobert Schumacher <roschuma@microsoft.com>2017-08-25 16:03:57 -0700
commit98ee8a949ad4bfdfa9bf0411b552a23c923eaff7 (patch)
tree84ffd2ba562550286e5327ccb8946076942f0934 /toolsrc/include/metrics.h
parent34bd87c9fcfb1ac9269c75db96852b64ed754d11 (diff)
downloadvcpkg-98ee8a949ad4bfdfa9bf0411b552a23c923eaff7.tar.gz
vcpkg-98ee8a949ad4bfdfa9bf0411b552a23c923eaff7.zip
[vcpkg] Trap Ctrl-C, enable thread safety for global data structures
Diffstat (limited to 'toolsrc/include/metrics.h')
-rw-r--r--toolsrc/include/metrics.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/toolsrc/include/metrics.h b/toolsrc/include/metrics.h
index 1f5ae2f32..8eae426de 100644
--- a/toolsrc/include/metrics.h
+++ b/toolsrc/include/metrics.h
@@ -2,19 +2,27 @@
#include <string>
+#include "vcpkg_Util.h"
+
namespace vcpkg::Metrics
{
- void set_send_metrics(bool should_send_metrics);
- void set_print_metrics(bool should_print_metrics);
- void set_user_information(const std::string& user_id, const std::string& first_use_time);
- void init_user_information(std::string& user_id, std::string& first_use_time);
+ struct Metrics : Util::ResourceBase
+ {
+ void set_send_metrics(bool should_send_metrics);
+ void set_print_metrics(bool should_print_metrics);
+ void set_user_information(const std::string& user_id, const std::string& first_use_time);
+ void init_user_information(std::string& user_id, std::string& first_use_time);
- void track_metric(const std::string& name, double value);
- void track_property(const std::string& name, const std::string& value);
- void track_property(const std::string& name, const std::wstring& value);
- bool get_compiled_metrics_enabled();
- std::wstring get_SQM_user();
+ void track_metric(const std::string& name, double value);
+ void track_property(const std::string& name, const std::string& value);
+ void track_property(const std::string& name, const std::wstring& value);
+
+ void upload(const std::string& payload);
+ void flush();
+ };
- void upload(const std::string& payload);
- void flush();
+ extern Util::LockGuarded<Metrics> g_metrics;
+
+ std::wstring get_SQM_user();
+ bool get_compiled_metrics_enabled();
}