jvmti_rs/wrapper/jvmtifns/
timers.rs1use crate::{
2 errors::*,
3 JVMTIEnv,
4 objects::*,
5 sys::*,
6};
7
8impl<'a> JVMTIEnv<'a> {
9 pub fn get_current_thread_cpu_time(&self) -> Result<jlong> {
10 Ok(jvmti_call_number_result!(self.jvmti_raw(), jlong,
11 GetCurrentThreadCpuTime
12 ))
13 }
14
15 pub fn get_thread_cpu_time(&self, thread: &JThreadID) -> Result<jlong> {
16 Ok(jvmti_call_number_result!(self.jvmti_raw(), jlong,
17 GetThreadCpuTime,
18 thread.into()
19 ))
20 }
21
22 pub fn get_time(&self) -> Result<jlong> {
23 Ok(jvmti_call_number_result!(self.jvmti_raw(), jlong,
24 GetTime
25 ))
26 }
27
28 pub fn get_current_thread_cpu_timer_info(&self) -> Result<JTimerInfo> {
29 let res = jvmti_call_number_result!(self.jvmti_raw(), {JTimerInfo::empty_raw()},
30 GetCurrentThreadCpuTimerInfo
31 );
32 Ok(res.into())
33 }
34
35 pub fn get_thread_cpu_timer_info(&self) -> Result<JTimerInfo> {
36 let res = jvmti_call_number_result!(self.jvmti_raw(), {JTimerInfo::empty_raw()},
37 GetThreadCpuTimerInfo
38 );
39 Ok(res.into())
40 }
41
42 pub fn get_timer_info(&self) -> Result<JTimerInfo> {
43 let res = jvmti_call_number_result!(self.jvmti_raw(), {JTimerInfo::empty_raw()},
44 GetTimerInfo
45 );
46 Ok(res.into())
47 }
48
49 pub fn get_available_processors(&self) -> Result<jint> {
50 Ok(jvmti_call_number_result!(self.jvmti_raw(), jint,
51 GetAvailableProcessors
52 ))
53 }
54}