Esempio n. 1
0
File: main.c Progetto: yydaor/LCUI
static int 
LCUIApp_RunTask( LCUI_App *app )
{ 
	LCUI_Task *task;

	Queue_Lock( &app->tasks );
	task = Queue_Get( &app->tasks, 0 );
	if( task == NULL ) {
		Queue_Unlock( &app->tasks );
		return -1;
	}
	Queue_DeletePointer( &app->tasks, 0 );
	if( task->func == NULL ) {
		Queue_Unlock( &app->tasks );
		return -2;
	}
	Queue_Unlock( &app->tasks );
	/* 调用函数指针指向的函数,并传递参数 */
	task->func( task->arg[0], task->arg[1] );
	/* 若需要在调用回调函数后销毁参数 */
	if( task->destroy_arg[0] ) {
		free( task->arg[0] );
	}
	if( task->destroy_arg[1] ) {
		free( task->arg[1] );
	}
	free( task );
	return 0;
}
Esempio n. 2
0
File: task.c Progetto: lc-soft/LCUI
int LCUITask_Run(LCUI_Task task)
{
	if (task && task->func) {
		task->func(task->arg[0], task->arg[1]);
		return 0;
	}
	return -1;
}