#include "engine/declarations.h"

#include "declarations_app.h"
#include "main_app.h"

/* This is the main() function for application called by the engine.
   Do not remove include lines above. */



int main_app(__UNUSED__ int argc, __UNUSED__ char **argv) {
	struct t_ctx *tp;

	/* Create universe roller thread... */
	if((tp = thread_spawn(NULL, worker_roller, NULL, NULL, NULL,
		THREAD_CLASS_APP, IS_NO)) == NULL) {

		return(-1);
	}

	/* ...and wait for it to start */
	while(1) {
		if(tp->tr == THREAD_STATE_RUN ||
			tp->tr == THREAD_STATE_IDLE ||
			tp->tr == THREAD_STATE_STOP) {

			break;
		}

		/* Do not burn the cpu */
		(void) timer_wait(0,
			TIMER_RESOLUTION_THREADAGAIN);
	}

	/* Do not use exit() here, as this is not real main() function */
	return(0);
}
