diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-08-25 16:03:57 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-08-25 16:03:57 -0700 |
| commit | 98ee8a949ad4bfdfa9bf0411b552a23c923eaff7 (patch) | |
| tree | 84ffd2ba562550286e5327ccb8946076942f0934 /toolsrc/include/metrics.h | |
| parent | 34bd87c9fcfb1ac9269c75db96852b64ed754d11 (diff) | |
| download | vcpkg-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.h | 30 |
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(); } |
