jvmti_rs/wrapper/jvmtifns/
event_management.rs

1use std::ptr;
2
3use crate::{errors::*, JVMTIEnv, JvmtiEvent, JvmtiEventMode, objects::*};
4use crate::sys::jvmtiEventCallbacks;
5
6impl<'a> JVMTIEnv<'a> {
7    pub fn set_event_callbacks(&self, callbacks: &JEventCallbacks) -> Result<()> {
8        let jvmti_callbacks: *const jvmtiEventCallbacks = &(*callbacks).into();
9        jvmti_call!(self.jvmti_raw(), SetEventCallbacks,
10            jvmti_callbacks,
11            JEventCallbacks::size_of_callbacks()
12        )
13    }
14
15    pub fn set_event_notification_mode(&self, mode: JvmtiEventMode,
16                                       event_type: JvmtiEvent,
17                                       event_thread: &Option<JThreadID>) -> Result<()> {
18        jvmti_call!(self.jvmti_raw(), SetEventNotificationMode,
19            mode.into(),
20            event_type.into(),
21            event_thread.map_or_else(|| ptr::null_mut(), |t| t.into())
22        )
23    }
24
25    pub fn generate_events(&self, event_type: JvmtiEvent) -> Result<()> {
26        jvmti_call!(self.jvmti_raw(), GenerateEvents,
27            event_type.into()
28        )
29    }
30}