Index: src/platform.h |
diff --git a/src/platform.h b/src/platform.h |
index 4b558df172385085d76a40b4efe6cc2a0e673373..d4c91b4a1db1e05f3409c945b70f1af879ac30ef 100644 |
--- a/src/platform.h |
+++ b/src/platform.h |
@@ -760,10 +760,28 @@ class Sampler { |
void Start(); |
void Stop(); |
- // Is the sampler used for profiling? |
- bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; } |
- void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); } |
- void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); } |
+ // Whether the sampling thread should use this Sampler for CPU profiling? |
+ bool IsProfiling() const { |
+ return NoBarrier_Load(&profiling_) > 0 && |
+ !NoBarrier_Load(&has_processing_thread_); |
+ } |
+ // Perform platform-specific initialization before DoSample() may be invoked. |
+ void StartSampling(); |
+ // Perform platform-specific cleanup after samping. |
+ void StopSampling(); |
+ void IncreaseProfilingDepth() { |
+ if (NoBarrier_AtomicIncrement(&profiling_, 1) == 1) { |
+ StartSampling(); |
+ } |
+ } |
+ void DecreaseProfilingDepth() { |
+ if (!NoBarrier_AtomicIncrement(&profiling_, -1)) { |
+ StopSampling(); |
+ } |
+ } |
+ void SetHasProcessingThread(bool value) { |
+ NoBarrier_Store(&has_processing_thread_, value); |
+ } |
// Whether the sampler is running (that is, consumes resources). |
bool IsActive() const { return NoBarrier_Load(&active_); } |
@@ -790,6 +808,7 @@ class Sampler { |
const int interval_; |
Atomic32 profiling_; |
Atomic32 active_; |
+ Atomic32 has_processing_thread_; |
PlatformData* data_; // Platform specific data. |
int samples_taken_; // Counts stack samples taken. |
DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |