@@ -12,22 +12,23 @@ pub struct Cpus {
1212 process_handle : ProcessHandle ,
1313 combined_thread_handle : ThreadHandle ,
1414 cpus : Vec < Cpu > ,
15- idle_frame_label : FrameHandle ,
1615}
1716
1817pub struct Cpu {
1918 pub name : StringHandle ,
2019 pub thread_handle : ThreadHandle ,
2120 pub context_switch_data : ThreadContextSwitchData ,
21+ pub idle_frame : FrameHandle ,
2222 current_tid : Option < ( i32 , StringHandle , u64 ) > ,
2323}
2424
2525impl Cpu {
26- pub fn new ( name : StringHandle , thread_handle : ThreadHandle ) -> Self {
26+ pub fn new ( name : StringHandle , thread_handle : ThreadHandle , idle_frame : FrameHandle ) -> Self {
2727 Self {
2828 name,
2929 thread_handle,
3030 context_switch_data : Default :: default ( ) ,
31+ idle_frame,
3132 current_tid : None ,
3233 }
3334 }
@@ -113,38 +114,36 @@ impl Cpus {
113114 pub fn new ( start_time : Timestamp , profile : & mut Profile ) -> Self {
114115 let process_handle = profile. add_process ( "CPU" , 0 , start_time) ;
115116 let combined_thread_handle = profile. add_thread ( process_handle, 0 , start_time, true ) ;
116- let idle_string = profile. handle_for_string ( "<Idle>" ) ;
117- let idle_frame_label = profile. handle_for_frame_with_label (
118- combined_thread_handle,
119- idle_string,
120- CategoryHandle :: OTHER ,
121- FrameFlags :: empty ( ) ,
122- ) ;
123117 Self {
124118 start_time,
125119 process_handle,
126120 combined_thread_handle,
127121 cpus : Vec :: new ( ) ,
128- idle_frame_label,
129122 }
130123 }
131124
132125 pub fn combined_thread_handle ( & self ) -> ThreadHandle {
133126 self . combined_thread_handle
134127 }
135128
136- pub fn idle_frame_label ( & self ) -> FrameHandle {
137- self . idle_frame_label
138- }
139-
140129 pub fn get_mut ( & mut self , cpu : usize , profile : & mut Profile ) -> & mut Cpu {
141130 while self . cpus . len ( ) <= cpu {
142131 let i = self . cpus . len ( ) ;
143132 let thread = profile. add_thread ( self . process_handle , i as u32 , self . start_time , false ) ;
144133 let name = format ! ( "CPU {i}" ) ;
145134 profile. set_thread_name ( thread, & name) ;
146- self . cpus
147- . push ( Cpu :: new ( profile. handle_for_string ( & name) , thread) ) ;
135+ let idle_string = profile. handle_for_string ( "<Idle>" ) ;
136+ let idle_frame = profile. handle_for_frame_with_label (
137+ thread,
138+ idle_string,
139+ CategoryHandle :: OTHER ,
140+ FrameFlags :: empty ( ) ,
141+ ) ;
142+ self . cpus . push ( Cpu :: new (
143+ profile. handle_for_string ( & name) ,
144+ thread,
145+ idle_frame,
146+ ) ) ;
148147 }
149148 & mut self . cpus [ cpu]
150149 }
0 commit comments