Example #1
0
File: main.c Project: ADTSH/io
int main(int argc, const char *argv[])
{
	int exitResult;
	IoState *self;
#ifdef IO_SHOW_STATS
	size_t t1 = clock();
	size_t maxAllocatedBytes;
	double collectorTime;
	size_t sweepCount;
#endif


	self = IoState_new();
#ifdef IOBINDINGS
	IoState_setBindingsInitCallback(self, (IoStateBindingsInitCallback *)IoAddonsInit);
#endif
	IoState_init(self);
	IoState_argc_argv_(self, argc, argv);
	//IoState_doCString_(self, "some test code...");
	IoState_runCLI(self);
	exitResult = IoState_exitResult(self);

#ifdef IO_SHOW_STATS
	maxAllocatedBytes = io_maxAllocatedBytes();
	collectorTime = Collector_timeUsed(self->collector);
	sweepCount = self->collector->sweepCount;
#endif

	IoState_free(self);

#ifdef IO_SHOW_STATS
	{
		float totalTime = (clock()-t1)/(float)CLOCKS_PER_SEC;
		printf("[ %.3fs user  %.3fs total  %.1f%% gc  %i sweeps  %i frees  %.3fmb max ]\n",
			   System_UserTime(),
			   totalTime,
			   100.0*collectorTime/totalTime,
			   (int)sweepCount,
			   (int)io_frees(),
			   maxAllocatedBytes/1048576.0);

		if(io_allocatedBytes() != 0)
		{
			printf("warning: %i bytes in %i blocks not freed:\n\n",
				   (int)io_allocatedBytes(), (int)(io_allocs() - io_frees()));
			io_showUnfreed();
		}
		else
		{
			printf("[ no memory leaks found ]\n");
		}
	}
#endif

	//printf("exitResult = %i\n", exitResult);
	return exitResult;
}
Example #2
0
File: main.c Project: Akiyah/io
int main(int argc, const char *argv[])
{
  IoState *state = IoState_new();
  int v;
  IoState_pauseGarbageCollector(state);
  IoDesktopInit(state);
  
  IoObject_setSlot_to_(state->lobby, 
    IoState_stringWithCString_(state, "distribution"), 
    IoState_stringWithCString_(state, "IoPlayer"));

  IoState_errorCallback_( state, errorCallback );

  IoState_resumeGarbageCollector(state);
  v = IoState_main(state, argc, argv);
  /*IoState_free(state);*/
  return v;
}
Example #3
0
IoObject *IoThread_createThread(IoObject *self, IoObject *locals, IoMessage *m)
{
	IoSeq *s = IoMessage_locals_seqArgAt_(m, locals, 0);
	IoState *newState = IoState_new();
	Thread *t;

	Thread_Init();

	t = Thread_new();

	IoThreadInfo *ti = IoThreadInfo_new();
	IoThreadInfo_setState_(ti, newState);
	IoThreadInfo_setThread_(ti, t);
	IoThreadInfo_setEvalString_(ti, CSTRING(s));

	Thread_setFunc_(t, IoThread_BeginThread);
	Thread_setFuncArg_(t, (void *)ti);
	Thread_start(t);

	return self;
}