How to use enif_schedule_nif?

In the c code of nif, a new function called in enif_schedule_nif. If the execution of the new function is also slow, do I need to call enif_schedule_nif again in the new function? The nif documentation has a sentence like “The calling NIF must use the return value of enif_schedule_nif as its own return value.” I wonder why this restriction is there?

Yes

The return value is used by the runtime system to determine what to do. If you return something else, the behavior is undefined.

unless you scheduled it onto a dirty scheduler of suitable type

is it the flags “Must be set to 0 for a regular NIF.”, It needs to be called “enif_schedule_nif” again ?

Yes, flags equal to 0 will schedule it on a normal scheduler where you need to take care of yielding, if necessary, by calling enif_schedule_nif()

Ok, thank you!