mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-17 03:12:21 +08:00
Revert "Make Profiler::active_profiler a unique pointer" and add comment
This commit is contained in:
parent
065c7e570c
commit
4dd9c4889e
@ -25,7 +25,6 @@
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#include <memory>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -125,7 +124,7 @@ struct Profiler {
|
|||||||
OutputBuffer* output_buffer;
|
OutputBuffer* output_buffer;
|
||||||
Future<Void> actor;
|
Future<Void> actor;
|
||||||
sigset_t profilingSignals;
|
sigset_t profilingSignals;
|
||||||
static std::unique_ptr<Profiler> active_profiler;
|
static Profiler* active_profiler;
|
||||||
BinaryWriter environmentInfoWriter;
|
BinaryWriter environmentInfoWriter;
|
||||||
INetwork* network;
|
INetwork* network;
|
||||||
timer_t periodicTimer;
|
timer_t periodicTimer;
|
||||||
@ -257,7 +256,8 @@ struct Profiler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<Profiler> Profiler::active_profiler;
|
// Outlives main
|
||||||
|
Profiler* Profiler::active_profiler = nullptr;
|
||||||
|
|
||||||
std::string findAndReplace( std::string const& fn, std::string const& symbol, std::string const& value ) {
|
std::string findAndReplace( std::string const& fn, std::string const& symbol, std::string const& value ) {
|
||||||
auto i = fn.find(symbol);
|
auto i = fn.find(symbol);
|
||||||
@ -283,12 +283,14 @@ void startProfiling(INetwork* network, Optional<int> maybePeriod /*= {}*/, Optio
|
|||||||
outputFile = findAndReplace(findAndReplace(findAndReplace(outputFile, "%ADDRESS%", findAndReplace(network->getLocalAddress().toString(), ":", ".")), "%PID%", format("%d", getpid())), "%TID%", format("%llx", (long long)sys_gettid()));
|
outputFile = findAndReplace(findAndReplace(findAndReplace(outputFile, "%ADDRESS%", findAndReplace(network->getLocalAddress().toString(), ":", ".")), "%PID%", format("%d", getpid())), "%TID%", format("%llx", (long long)sys_gettid()));
|
||||||
|
|
||||||
if (!Profiler::active_profiler)
|
if (!Profiler::active_profiler)
|
||||||
Profiler::active_profiler = std::make_unique<Profiler>( period, outputFile, network );
|
Profiler::active_profiler = new Profiler( period, outputFile, network );
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopProfiling() {
|
void stopProfiling() {
|
||||||
if (Profiler::active_profiler) {
|
if (Profiler::active_profiler) {
|
||||||
Profiler::active_profiler.reset();
|
Profiler *p = Profiler::active_profiler;
|
||||||
|
Profiler::active_profiler = nullptr;
|
||||||
|
delete p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user