Function hadean::hadean::init[][src]

pub fn init() -> Option<Machine>
Expand description

Initialise the runtime for the current process and jump to the target function (if applicable).


The target function refers to the function specified when the user calls spawn. Each process starts at the main function of the user application. It is expected that init gets called at the start of the application. On the root process, init returns and execution continues. On subsequent child processes, this function causes execution to jump to the target function.

The init function should ideally be the first function called inside the application. While it is technically possible to run some code before calling init, you cannot rely on any code being executed once the target function returns. Ensure that any object put on the stack prior to this point has been deallocated/destroyed. If setup/teardown is essential, consider using trampoline functions.


The machine on which the root process was spawned. The root process can spawn additional things on its machine, although other processes will get a None as a return value. When the machine is dropped, the Platform will reuse this machine.


This function panics upon unsuccessful initialisation.