Function gstd::critical::take_hook

source ·
pub fn take_hook() -> Option<Box<dyn FnMut()>>
Expand description

Removes current hook and returns it.

Don’t use it at all if you use #[gstd::async_init] or #[gstd::async_main].

Must be called at the end of init or handle to not blow up map because hook is set on per-message basis:

use gstd::critical;

#[no_mangle]
extern "C" fn handle() {
    critical::set_hook(|| {
        // some code...
    });

    // handle code...

    let _ = critical::take_hook();
}