Allocate, configure and start the main-loop threads.
Put all main-loop data into the mainloop_data structure.
Pass a pointer to the mainloop_definition, to avoid a useless copy.