Type Alias ucm_event_callback_t

Source
pub type ucm_event_callback_t = Option<unsafe extern "C" fn(event_type: ucm_event_type_t, event: *mut ucm_event_t, arg: *mut c_void)>;
Expand description

@brief Memory event callback.

This type describes a callback which handles memory events in the current process.

@param [in] event_type Type of the event being fired. see @ref ucm_event_type_t. @param [inout] event Event information. This structure can be updated by this callback, as described below. @param [in] arg User-defined argument as passed to @ref ucm_set_event_handler.

Events are dispatched in order of callback priority (low to high).

The fields of the relevant part of the union are initialized as follows:

  • “result” - to an invalid erroneous return value (depends on the specific event).
  • the rest - to the input parameters of the event.

The callback is allowed to modify the fields, and those modifications will be passed to the next callback. Also, the callback is allowed to modify the result, but only if it’s currently invalid. A valid result indicates that a previous callback already performed the requested memory operation, so a callback should refrain from actions with side-effects in this case.

If the result is still invalid after all callbacks are called, the parameters, possibly modified by the callbacks, will be passed to the original handler.

Important Note: The callback must not call any memory allocation routines, or anything which may trigger or wait for memory allocation, because it may lead to deadlock or infinite recursion.

@todo describe use cases

Aliased Type§

enum ucm_event_callback_t {
    None,
    Some(unsafe extern "C" fn(_: ucm_event_type, _: *mut ucm_event, _: *mut c_void)),
}

Variants§

§1.0.0

None

No value.

§1.0.0

Some(unsafe extern "C" fn(_: ucm_event_type, _: *mut ucm_event, _: *mut c_void))

Some value of type T.