diff --git a/src/lib.rs b/src/lib.rs index 76cc2b5..613f5c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -142,6 +142,10 @@ cfg_if! { pub fn deserialize(_: [u8; 1]) -> Self { RtPriorityThreadInfo{_dummy: 0} } + /// Returns the PID of the process containing the thread (fallback: always -1). + pub fn pid(&self) -> i32 { + -1 + } } /// Fallback implementation that performs no operation for unsupported platforms. pub fn promote_current_thread_to_real_time_internal(_: u32, audio_samplerate_hz: u32) -> Result { diff --git a/src/rt_linux.rs b/src/rt_linux.rs index 1eabe29..2a1ddb0 100644 --- a/src/rt_linux.rs +++ b/src/rt_linux.rs @@ -62,6 +62,10 @@ impl RtPriorityThreadInfoInternal { pub fn deserialize(bytes: [u8; std::mem::size_of::()]) -> Self { unsafe { std::mem::transmute::<[u8; std::mem::size_of::()], Self>(bytes) } } + /// Returns the PID of the process containing the thread. + pub fn pid(&self) -> libc::pid_t { + self.pid + } } impl PartialEq for RtPriorityThreadInfoInternal {