|
1 | 1 | #ifndef SRC_NSOLID_NSOLID_CPU_PROFILER_H_ |
2 | 2 | #define SRC_NSOLID_NSOLID_CPU_PROFILER_H_ |
3 | 3 |
|
4 | | -#include <nsolid/nsolid_api.h> |
5 | | -#include <nsolid/nsolid_util.h> |
6 | | -#include <v8.h> |
7 | | -#include <v8-profiler.h> |
8 | | -#include <tuple> |
9 | 4 | #include <map> |
| 5 | +#include "nsolid.h" |
| 6 | +#include "nsolid/nsolid_util.h" |
| 7 | +#include "nsuv-inl.h" |
10 | 8 |
|
11 | | -#include "asserts-cpp/asserts.h" |
| 9 | +// pre-declarations. |
| 10 | +namespace v8 { |
| 11 | +class CpuProfiler; |
| 12 | +class CpuProfile; |
| 13 | +} // namespace v8 |
12 | 14 |
|
13 | 15 | namespace node { |
14 | 16 | namespace nsolid { |
15 | 17 |
|
16 | | - |
17 | | -class NSolidCpuProfiler { |
| 18 | +struct CpuProfilerStor { |
18 | 19 | public: |
19 | | - struct CpuProfilerStor { |
20 | | - CpuProfilerStor(uint64_t timeout, |
21 | | - const std::string& title, |
22 | | - void* data, |
23 | | - CpuProfiler::cpu_profiler_proxy_sig proxy, |
24 | | - internal::deleter_sig deleter): |
25 | | - status_(0), |
26 | | - timeout_(timeout), |
27 | | - title_(title), |
28 | | - profiler_(nullptr), |
29 | | - profile_(nullptr), |
30 | | - proxy_(proxy), |
31 | | - data_(data, deleter) { |
32 | | - } |
33 | | - |
34 | | - ~CpuProfilerStor() { |
35 | | - if (profile_) { |
36 | | - profile_->Delete(); |
37 | | - profile_ = nullptr; |
38 | | - } |
39 | | - |
40 | | - if (profiler_) { |
41 | | - profiler_->Dispose(); |
42 | | - profiler_ = nullptr; |
43 | | - } |
44 | | - } |
45 | | - |
46 | | - int status_; |
47 | | - uint64_t timeout_; |
48 | | - std::string title_; |
49 | | - v8::CpuProfiler* profiler_; |
50 | | - v8::CpuProfile* profile_; |
51 | | - CpuProfiler::cpu_profiler_proxy_sig proxy_; |
52 | | - internal::user_data data_; |
53 | | - }; |
| 20 | + explicit CpuProfilerStor(uint64_t thread_id, |
| 21 | + uint64_t timeout, |
| 22 | + const std::string& title, |
| 23 | + void* data, |
| 24 | + CpuProfiler::cpu_profiler_proxy_sig proxy, |
| 25 | + internal::deleter_sig deleter); |
| 26 | + NSOLID_DELETE_DEFAULT_CONSTRUCTORS(CpuProfilerStor) |
| 27 | + ~CpuProfilerStor(); |
54 | 28 |
|
| 29 | + private: |
| 30 | + friend class NSolidCpuProfiler; |
| 31 | + uint64_t thread_id_; |
| 32 | + uint64_t timeout_; |
| 33 | + std::string title_; |
| 34 | + v8::CpuProfiler* profiler_; |
| 35 | + v8::CpuProfile* profile_; |
| 36 | + CpuProfiler::cpu_profiler_proxy_sig proxy_; |
| 37 | + internal::user_data data_; |
| 38 | +}; |
55 | 39 |
|
| 40 | +class NSolidCpuProfiler { |
| 41 | + public: |
56 | 42 | static NSolidCpuProfiler* Inst(); |
57 | 43 |
|
58 | 44 | int TakeCpuProfile(SharedEnvInst envinst, |
@@ -99,7 +85,6 @@ class NSolidCpuProfiler { |
99 | 85 | ~NSolidCpuProfiler(); |
100 | 86 | }; |
101 | 87 |
|
102 | | - |
103 | 88 | } // namespace nsolid |
104 | 89 | } // namespace node |
105 | 90 |
|
|
0 commit comments