Added locking to perf trace log.

This commit is contained in:
Pedro Pinto committed 2018-10-08 14:10:56 +00:00
1 parent 931d5dad01
commit f324504df1
1 file changed
+3
@@ -15,6 +15,7 @@
#include <fmt/format.h>
#include <iostream>
#include <tbb/concurrent_queue.h>
#include <mutex>
namespace bts {
@@ -83,6 +84,7 @@ struct PerfTraceLog::PImpl {
std::unique_ptr<SQLite::Statement> insert_statement;
tbb::concurrent_queue<PerfTrace> pending_traces;
std::string session_start;
std::mutex lock;
};
PerfTraceLog::PerfTraceLog() : me() {
@@ -129,6 +131,7 @@ int PerfTraceLog::persist_traces() {
}
void PerfTraceLog::store(std::vector<PerfTrace> const &traces) {
std::lock_guard<std::mutex> l(me->lock);
try {
for (auto const &t : traces) {
me->insert_statement->bind(":version",