add enif_schedule_nif() to NIF API

In the #erlang IRC channel Anthony Ramine mentioned the idea of allowing a
NIF to use an emulator trap to schedule another NIF for later execution as
a way of preventing long-running NIF tasks from interfering with the VM's
schedulers. This is exactly how dirty NIFs are scheduled, so this commit
refactors that code so it can support a new enif_schedule_nif() API
function.

The enif_schedule_nif() function allows a long-running NIF to be broken
into separate NIF invocations that the emulator calls serially. The NIF
first executes part of the long-running task, then passes a NIF to
enif_schedule_nif() to schedule it for later execution so it can continue
the task. Since the emulator regains control in between invocations, this
helps avoid problems caused by native code tying up scheduler threads for
too long.

Also add documentation and a test for enif_schedule_nif().