web_service: stop using std::future + callback style async

This commit is contained in:
Weiyi Wang
2018-09-12 12:22:48 -04:00
parent 0a4d338ffa
commit 77c1f647cb
23 changed files with 329 additions and 457 deletions

View File

@ -2,7 +2,9 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <thread>
#include "common/assert.h"
#include "common/detached_tasks.h"
#include "web_service/telemetry_json.h"
#include "web_service/web_backend.h"
@ -81,8 +83,12 @@ void TelemetryJson::Complete() {
SerializeSection(Telemetry::FieldType::UserConfig, "UserConfig");
SerializeSection(Telemetry::FieldType::UserSystem, "UserSystem");
auto content = TopSection().dump();
// Send the telemetry async but don't handle the errors since they were written to the log
future = PostJson(endpoint_url, TopSection().dump(), true);
Common::DetachedTasks::AddTask(
[host{this->host}, username{this->username}, token{this->token}, content]() {
Client{host, username, token}.PostJson("/telemetry", content, true);
});
}
} // namespace WebService