[self-profiler] Use ThreadId::as_u64()
instead of transmute
This commit is contained in:
parent
8647aa1a2c
commit
ea42b1c5b8
2 changed files with 3 additions and 7 deletions
|
@ -23,6 +23,7 @@
|
|||
#![feature(integer_atomics)]
|
||||
#![feature(test)]
|
||||
#![feature(associated_type_bounds)]
|
||||
#![feature(thread_id_value)]
|
||||
#![cfg_attr(unix, feature(libc))]
|
||||
#![allow(rustc::default_hash_types)]
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ use std::fs;
|
|||
use std::path::Path;
|
||||
use std::process;
|
||||
use std::sync::Arc;
|
||||
use std::thread::ThreadId;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::u32;
|
||||
|
||||
|
@ -149,10 +148,6 @@ const EVENT_FILTERS_BY_NAME: &[(&str, EventFilter)] = &[
|
|||
("query-keys", EventFilter::QUERY_KEYS),
|
||||
];
|
||||
|
||||
fn thread_id_to_u32(tid: ThreadId) -> u32 {
|
||||
unsafe { std::mem::transmute::<ThreadId, u64>(tid) as u32 }
|
||||
}
|
||||
|
||||
/// Something that uniquely identifies a query invocation.
|
||||
pub struct QueryInvocationId(pub u32);
|
||||
|
||||
|
@ -318,7 +313,7 @@ impl SelfProfilerRef {
|
|||
) {
|
||||
drop(self.exec(event_filter, |profiler| {
|
||||
let event_id = StringId::new_virtual(query_invocation_id.0);
|
||||
let thread_id = thread_id_to_u32(std::thread::current().id());
|
||||
let thread_id = std::thread::current().id().as_u64() as u32;
|
||||
|
||||
profiler.profiler.record_instant_event(
|
||||
event_kind(profiler),
|
||||
|
@ -477,7 +472,7 @@ impl<'a> TimingGuard<'a> {
|
|||
event_kind: StringId,
|
||||
event_id: EventId,
|
||||
) -> TimingGuard<'a> {
|
||||
let thread_id = thread_id_to_u32(std::thread::current().id());
|
||||
let thread_id = std::thread::current().id().as_u64() as u32;
|
||||
let raw_profiler = &profiler.profiler;
|
||||
let timing_guard =
|
||||
raw_profiler.start_recording_interval_event(event_kind, event_id, thread_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue