Skip to main content

Module Events

In this chapter you'll learn about module boot and shutdown events.

Boot/Shutdown Mechanism

Jenova Module Mapper has a mechanism to call into the compiled Jenova Module when it's loaded and unloaded.

These events are known as "Boot/Shutdown Events"

Boot Event

When a compiled Jenova Module gets mapped into memory and prepared for execution by Module Mapper, Interpreter calls JenovaBoot() function in the module if it is defined. If the function returns false Interpreter stops the execution until the next compile.

Shutdown Event

Now when the mapped module is being unloaded before a Hot-Reload or shutdown, Interpreter calls JenovaShutdown() function in the module if it is defined. If the function returns false Interpreter doesn't free the memory occupied by the module.

Usecase

To add the mechanism to your project, Simply create a new C++ Script and in the Create Script window select "Boot" template.

GuideImage_JenovaFrameworkAnatomy

Create Script Window, Using Boot template to create Boot Script.

Here's the basic code for Boot script :

Jenova C++ Boot Script
// Jenova SDK
#include <JenovaSDK.h>

// Jenova Module Is Loading
JENOVA_EXPORT bool JenovaBoot()
{
/* Initialize Your GDExtension Class Here */
return true;
}

// Jenova Module Is Unloading
JENOVA_EXPORT bool JenovaShutdown()
{
/* Dispose Your GDExtension Class Here */
return true;
}

Boot/Shutdown events can be used for the following purposes:

  • Registration and Hot-Reloading of Nested Extensions
  • Initialization/Release of CUDA, OpenCV, OpenCL, etc.
  • Allocation of Global Memory and Variables
  • Save/Load Configuration from Disk
  • And more...

You'll learn more about Boot/Shutdown events in Nested Extensions chapter.