jvmti_rs/wrapper/objects/
jmonitor_usage.rs1use crate::{builder::*, JVMTIEnv, objects::*};
2use crate::sys;
3use crate::sys::jthread;
4
5#[derive(Clone, Debug)]
6pub struct JMonitorUsage<'a> {
7 internal: sys::jvmtiMonitorUsage,
8
9 pub owner: JThreadID<'a>,
10 pub entry_count: u32,
11 pub waiters: Vec<JThreadID<'a>>,
12 pub notify_waiters: Vec<JThreadID<'a>>,
13}
14
15impl<'a> JMonitorUsage<'a> {
16 pub fn new<'b: 'a>(usage: sys::jvmtiMonitorUsage, jvmti: &'b JVMTIEnv<'a>) -> Self {
17 let waiters: MutAutoDeallocateObjectArrayBuilder<jthread> = MutAutoDeallocateObjectArrayBuilder::create(usage.waiter_count, usage.waiters);
18 let notify_waiters: MutAutoDeallocateObjectArrayBuilder<jthread> = MutAutoDeallocateObjectArrayBuilder::create(usage.notify_waiter_count, usage.notify_waiters);
19
20 return JMonitorUsage {
21 internal: usage,
22
23 owner: usage.owner.into(),
24 entry_count: usage.entry_count as u32,
25 waiters: waiters.build(jvmti),
26 notify_waiters: notify_waiters.build(jvmti),
27 };
28 }
29}
30
31impl<'a> ::std::ops::Deref for JMonitorUsage<'a> {
32 type Target = sys::jvmtiMonitorUsage;
33
34 fn deref(&self) -> &Self::Target {
35 &self.internal
36 }
37}