@@ -11,33 +11,12 @@ use crate::{
1111 backends:: { pprof:: Pprof , Backend } ,
1212 error:: Result ,
1313 session:: { Session , SessionManager , SessionSignal } ,
14- timer:: Timer ,
14+ timer:: { Timer , TimerSignal } ,
1515} ;
1616
1717const LOG_TAG : & str = "Pyroscope::Agent" ;
1818
1919
20- /// A signal sent from the agent to the timer.
21- ///
22- /// Either schedules another wake-up, or asks
23- /// the timer thread to terminate.
24- #[ derive( Debug , Clone , Copy ) ]
25- pub enum AgentSignal {
26- // Thread termination was requested.
27- Terminate ,
28- // When to take the next snapshot using the `Backend`.
29- NextSnapshot ( u64 ) ,
30- }
31-
32- impl std:: fmt:: Display for AgentSignal {
33- fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
34- match self {
35- Self :: Terminate => write ! ( f, "Terminate" ) ,
36- Self :: NextSnapshot ( when) => write ! ( f, "NextSnapshot({})" , when) ,
37- }
38- }
39- }
40-
4120/// Pyroscope Agent Configuration. This is the configuration that is passed to the agent.
4221/// # Example
4322/// ```
@@ -275,7 +254,7 @@ impl PyroscopeAgentBuilder {
275254pub struct PyroscopeAgent {
276255 timer : Timer ,
277256 session_manager : SessionManager ,
278- tx : Option < Sender < AgentSignal > > ,
257+ tx : Option < Sender < TimerSignal > > ,
279258 handle : Option < JoinHandle < Result < ( ) > > > ,
280259 running : Arc < ( Mutex < bool > , Condvar ) > ,
281260
@@ -371,7 +350,7 @@ impl PyroscopeAgent {
371350
372351 while let Ok ( signal) = rx. recv ( ) {
373352 match signal {
374- AgentSignal :: NextSnapshot ( until) => {
353+ TimerSignal :: NextSnapshot ( until) => {
375354 log:: trace!( target: LOG_TAG , "Sending session {}" , until) ;
376355
377356 // Generate report from backend
@@ -384,7 +363,7 @@ impl PyroscopeAgent {
384363 report,
385364 ) ?) ) ?
386365 }
387- AgentSignal :: Terminate => {
366+ TimerSignal :: Terminate => {
388367 log:: trace!( target: LOG_TAG , "Session Killed" ) ;
389368
390369 let ( lock, cvar) = & * pair;
@@ -420,8 +399,8 @@ impl PyroscopeAgent {
420399 // get tx and send termination signal
421400 if let Some ( sender) = self . tx . take ( ) {
422401 // best effort
423- let _ = sender. send ( AgentSignal :: NextSnapshot ( 0 ) ) ;
424- sender. send ( AgentSignal :: Terminate ) ?;
402+ let _ = sender. send ( TimerSignal :: NextSnapshot ( 0 ) ) ;
403+ sender. send ( TimerSignal :: Terminate ) ?;
425404 } else {
426405 log:: error!( "PyroscopeAgent - Missing sender" )
427406 }
0 commit comments