@@ -122,6 +122,41 @@ impl Profiler {
122
122
}
123
123
}
124
124
125
+ /// Creates a "start" event and returns a `DetachedTiming`.
126
+ /// To create the corresponding "event" event, yuu must call
127
+ /// `finish_recording_internal_event` with the returned
128
+ /// `DetachedTiming`
129
+ #[ inline]
130
+ pub fn start_recording_interval_event_detached (
131
+ & self ,
132
+ event_kind : StringId ,
133
+ event_id : EventId ,
134
+ thread_id : u32
135
+ ) -> DetachedTiming {
136
+ DetachedTiming {
137
+ event_id,
138
+ event_kind,
139
+ thread_id,
140
+ start_count : self . counter . since_start ( ) ,
141
+ }
142
+ }
143
+
144
+ /// Creates the corresponding "end" event for
145
+ /// the "start" event represented by `timing`. You
146
+ /// must have obtained `timing` from the same `Profiler`
147
+ pub fn finish_recording_interval_event (
148
+ & self ,
149
+ timing : DetachedTiming
150
+ ) {
151
+ drop ( TimingGuard {
152
+ profiler : self ,
153
+ event_id : timing. event_id ,
154
+ event_kind : timing. event_kind ,
155
+ thread_id : timing. thread_id ,
156
+ start_count : timing. start_count ,
157
+ } ) ;
158
+ }
159
+
125
160
fn record_raw_event ( & self , raw_event : & RawEvent ) {
126
161
self . event_sink
127
162
. write_atomic ( std:: mem:: size_of :: < RawEvent > ( ) , |bytes| {
@@ -130,6 +165,17 @@ impl Profiler {
130
165
}
131
166
}
132
167
168
+ /// Created by `Profiler::start_recording_interval_event_detached`.
169
+ /// Must be passed to `finish_recording_interval_event` to record an
170
+ /// "end" event.
171
+ #[ must_use]
172
+ pub struct DetachedTiming {
173
+ event_id : EventId ,
174
+ event_kind : StringId ,
175
+ thread_id : u32 ,
176
+ start_count : u64 ,
177
+ }
178
+
133
179
/// When dropped, this `TimingGuard` will record an "end" event in the
134
180
/// `Profiler` it was created by.
135
181
#[ must_use]
0 commit comments