当前位置: 首页>>代码示例>>C++>>正文


C++ Queue_GetTotal函数代码示例

本文整理汇总了C++中Queue_GetTotal函数的典型用法代码示例。如果您正苦于以下问题:C++ Queue_GetTotal函数的具体用法?C++ Queue_GetTotal怎么用?C++ Queue_GetTotal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Queue_GetTotal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TimerList_UpdateTimerPos

/** 更新定时器在定时器列表中的位置 */
static void TimerList_UpdateTimerPos(	LCUI_Queue *timer_list,
					timer_data *p_timer )
{
	int n, src_i=-1, des_i=-1;
	int64_t time_left, tmp_time_left;
	timer_data *p_tmp_timer;
	/* 计算该定时器的剩余定时时长 */
	time_left = LCUI_GetTicks( p_timer->start_time );
	time_left -= p_timer->pause_ms;
	time_left = p_timer->total_ms - time_left;
	/* 锁上定时器列表 */
	Queue_Lock( &global_timer_list );
	n = Queue_GetTotal( &global_timer_list );
	while(n--) {
		p_tmp_timer = (timer_data*)Queue_Get( &global_timer_list, n );
		if( !p_tmp_timer ) {
			continue;
		}
		/* 若找到自己的位置,则记录 */
		if( p_tmp_timer->id == p_timer->id ) {
			src_i = n;
			/* 如果已经找到目标位置,则退出循环 */
			if( des_i != -1 ) {
				break;
			}
			continue;
		}
		tmp_time_left = LCUI_GetTicks( p_tmp_timer->start_time );
		tmp_time_left -= p_tmp_timer->pause_ms;
		tmp_time_left = p_tmp_timer->total_ms - tmp_time_left;
		/* 若该定时器的剩余定时时长不大于当前定时器,则记录 */
		if( des_i == -1 && time_left >= tmp_time_left ) {
			DEBUG_MSG("src timer: %d, pos: %d, , cur_ms: %I64dms, des timer: %d, pos: %d, cur_ms: %I64dms\n",
				p_timer->id, src_i, LCUI_GetTicks(p_timer->start_time), 
				p_tmp_timer->id, des_i, LCUI_GetTicks(p_tmp_timer->start_time) );
			des_i = n;
			/* 如果已经找到源位置,则退出循环 */
			if( src_i != -1 ) {
				break;
			}
		}
	}
	/* 若目标位置无效,则将末尾作为目标位置 */
	if( des_i == -1 ) {
		DEBUG_MSG("tip\n");
		des_i = Queue_GetTotal( &global_timer_list )-1;
	}
	/* 若源位置和目标位置有效,则开始移动 */
	if( src_i != -1 ) {
		DEBUG_MSG("src: %d, des: %d\n", src_i, des_i );
		Queue_Move( &global_timer_list, des_i, src_i );
	}
	Queue_Unlock( &global_timer_list );
}
开发者ID:fshunj,项目名称:LCUI,代码行数:55,代码来源:timer.c

示例2: LCUIAppList_Delete

/* 从程序列表中删除一个LCUI程序信息 */
static int LCUIAppList_Delete( LCUI_ID app_id )
{
	int pos = -1;
	LCUI_App *app; 
	int i, total;  
	
	total = Queue_GetTotal(&LCUI_Sys.app_list);
	/* 如果程序总数大于0,查找程序信息所在队列的位置 */
	if (total > 0) { 
		for (i = 0; i < total; ++i) {
			app = Queue_Get(&LCUI_Sys.app_list, i);
			if(app->id == app_id) {
				pos = i;
				break;
			}
		}
		if(pos < 0) {
			return -1;
		}
	} else {
		return -1;
	}
	/* 从程序显示顺序队列中删除这个程序ID */ 
	Queue_Delete (&LCUI_Sys.app_list, pos); 
	return 0;
}
开发者ID:yydaor,项目名称:LCUI,代码行数:27,代码来源:main.c

示例3: LCUI_MainLoop_New

/* 新建一个主循环 */
LCUI_API LCUI_MainLoop*
LCUI_MainLoop_New( void )
{
	LCUI_MainLoop *loop;
	
	if( !init_mainloop_queue ) {
		LCUI_MainLoopQueue_Init();
		init_mainloop_queue = TRUE;
	}
	loop = LCUI_MainLoop_GetAvailable();
	if( loop == NULL ) {
		loop = (LCUI_MainLoop*)malloc(sizeof(LCUI_MainLoop));
		if( !loop ) {
			return NULL;
		}
	}
	loop->app_id = LCUIApp_GetSelfID();
	loop->quit = FALSE;
	loop->level = Queue_GetTotal( &mainloop_queue );
	loop->running = FALSE;
	Queue_AddPointer( &mainloop_queue, loop );
	/* 重新对主循环队列进行排序 */
	LCUI_MainLoopQueue_Sort();
	return loop;
}
开发者ID:yydaor,项目名称:LCUI,代码行数:26,代码来源:main.c

示例4: WidgetMsg_AddToTask

LCUI_API int WidgetMsg_AddToTask( LCUI_Widget *widget, WidgetMsgData *data_ptr )
{
	int i,n;
	LCUI_Queue *msg_func;
	LCUI_Task *task_ptr, task;
	
	/* LCUI系统消息不能作为任务让程序在主循环里处理 */
	if( data_ptr->msg_id < WIDGET_USER ) {
		return -1;
	}
	msg_func = Widget_GetMsgFunc( widget );
	if( msg_func == NULL ) {
		return -2;
	}
	n = Queue_GetTotal( msg_func );
	for(i=0; i<n; ++i) {
		task_ptr = (LCUI_Task*)Queue_Get( msg_func, i );
		if( task_ptr == NULL ) {
			continue;
		}
		if( task_ptr->id != data_ptr->msg_id ) {
			continue;
		}
		task.id = widget->app_id;
		task.func = task_ptr->func;
		task.arg[0] = widget;
		task.arg[1] = data_ptr->data.ptr;
		task.destroy_arg[0] = FALSE;
		task.destroy_arg[1] = data_ptr->need_free;
		AppTasks_Add( &task );
	}
	return 0;
}
开发者ID:fshunj,项目名称:LCUI,代码行数:33,代码来源:widget_msg.c

示例5: WidgetMsg_Connect

LCUI_API int WidgetMsg_Connect(	LCUI_Widget *widget,
				uint_t msg_id,
				WidgetProcFunc func )
{
	int i,n;
	LCUI_Queue *msg_func;
	LCUI_Task *task_ptr, task;

	msg_func = Widget_GetMsgFunc( widget );
	if( msg_func == NULL ) {
		return -1;
	}
	n = Queue_GetTotal( msg_func );
	for(i=0; i<n; ++i) {
		task_ptr = (LCUI_Task*)Queue_Get( msg_func, i );
		if( task_ptr == NULL ) {
			continue;
		}
		if( task_ptr->id != msg_id ) {
			continue;
		}
		task_ptr->func = (CallBackFunc)func;
		return 0;
	}
	task.id = msg_id;
	task.func = (CallBackFunc)func;
	return Queue_Add( msg_func, &task );
}
开发者ID:fshunj,项目名称:LCUI,代码行数:28,代码来源:widget_msg.c

示例6: proc_dev_list

/** 处理列表中的设备的数据 */
static void proc_dev_list( void *arg )
{
	LCUI_Queue *dev_list;
	dev_func_data *data_ptr;
	int total, i, timeout_count = 0;
	
	dev_list = (LCUI_Queue *)arg;
	while( LCUI_Active() ) {
		Queue_Lock( dev_list );
		total = Queue_GetTotal( dev_list );
		for(i=0; i<total; ++i) {
			data_ptr = (dev_func_data*)Queue_Get( dev_list, i );
			if( !data_ptr || !data_ptr->proc_func ) {
				continue;
			}
			if( data_ptr->proc_func() ) {
				++timeout_count;
			}
		}
		Queue_Unlock( dev_list );
		if( timeout_count > 20 ) {
			LCUI_MSleep( 10 );
			timeout_count = 0;
		}
		LCUI_MSleep( 5 );
	}
	LCUIThread_Exit(NULL);
}
开发者ID:FrankHB,项目名称:LCUI,代码行数:29,代码来源:device.c

示例7: GraphLayer_AddChild

LCUI_API int GraphLayer_AddChild(	LCUI_GraphLayer *des_ctnr,
					LCUI_GraphLayer *glayer )
{
	int i, total;
	LCUI_GraphLayer *tmp_child;
	//_DEBUG_MSG( "des_ctnr: %p, glayer: %p\n", des_ctnr, glayer );
	/* 容器图层必须有效 */
	if( !des_ctnr ) {
		return -1;
	}
	/* 子图层必须有效,并且不能有父图层 */
	if( !glayer || glayer->parent ) {
		//_DEBUG_MSG( "!glayer || glayer->parent\n" );
		return -2;
	}
	/* 根据队列中的z值,将子图层存放在队列中适当的位置 */
	total = Queue_GetTotal( &des_ctnr->child );
	for( i=0; i<total; ++i ) {
		tmp_child = (LCUI_GraphLayer*)Queue_Get( &des_ctnr->child, i );
		/* 如果比当前位置的图层的z值小,那就对比下一个位置的图层 */
		if( glayer->z_index < tmp_child->z_index ) {
			continue;
		}
		/* 将新图层插入至该位置 */
		Queue_InsertPointer( &des_ctnr->child, i, glayer );
		break;
	}
	/* 如果没找到位置,则直接添加至末尾 */
	if( i >= total ) {
		Queue_AddPointer( &des_ctnr->child, glayer );
	}
	glayer->parent = des_ctnr;
	return 0;
}
开发者ID:aem3372,项目名称:LCUI,代码行数:34,代码来源:graphlayer.c

示例8: GraphLayer_PrintChildList

LCUI_API int GraphLayer_PrintChildList( LCUI_GraphLayer *glayer )
{
	int i, n;
	LCUI_Queue *child_list;
	LCUI_GraphLayer *child;

	if( glayer == NULL ) {
		return -1;
	}
	child_list = &glayer->child;
	if(child_list == NULL) {
		return -1;
	}
	n = Queue_GetTotal( child_list );
	_DEBUG_MSG("total glayer: %d\n", n);
	for(i=0; i<n; ++i) {
		child = (LCUI_GraphLayer*)Queue_Get( child_list, i );
		if( child == NULL ) {
			continue;
		}
		printf("[%d] glayer: %p, z-index: %d, pos: (%d,%d), size: (%d, %d)\n",
			i, child, child->z_index, child->pos.x, child->pos.y,
			child->graph.w, child->graph.h );
	}
	return 0;
}
开发者ID:aem3372,项目名称:LCUI,代码行数:26,代码来源:graphlayer.c

示例9: GraphLayer_Sort

LCUI_API int GraphLayer_Sort( LCUI_GraphLayer *glayer )
{
	LCUI_GraphLayer *child_a, *child_b;
	int i, j, total;
	
	if( !glayer ) {
		return -1;
	}
	/* 排序前先锁上队列互斥锁 */
	Queue_Lock( &glayer->child );
	total = Queue_GetTotal( &glayer->child );
	/* 使用的是冒泡排序法 */
	for(j=0; j<total; ++j)
	for(i=total-1; i>=1; --i) {
		child_a = (LCUI_GraphLayer*)Queue_Get( &glayer->child, i );
		if( !child_a ) {
			continue;
		}
		child_b = (LCUI_GraphLayer*)Queue_Get( &glayer->child, i-1 );
		if( !child_b ) {
			continue;
		}
		if( child_a->z_index > child_b->z_index ) {
			Queue_Move( &glayer->child, i-1, i);
		}
	}
	/* 解开互斥锁 */
	Queue_Unlock( &glayer->child );
	return 0;
}
开发者ID:aem3372,项目名称:LCUI,代码行数:30,代码来源:graphlayer.c

示例10: GraphLayer_DeleteChild

LCUI_API int GraphLayer_DeleteChild( LCUI_GraphLayer *child_glayer )
{
	int i, total;
	LCUI_Queue *child_list;
	LCUI_GraphLayer *tmp_glayer;
	
	if( !child_glayer ) {
		return -1;
	}
	if(  !child_glayer->parent ) {
		return 0;
	}
	/* 引用父图层的子图层列表 */
	child_list = &child_glayer->parent->child;
	total = Queue_GetTotal( child_list );
	/* 查找子图层记录 */
	for( i=0; i<total; ++i ) {
		tmp_glayer = (LCUI_GraphLayer*)Queue_Get( child_list, i );
		/* 若找到则删除该子图层记录 */
		if( tmp_glayer == child_glayer ) {
			Queue_DeletePointer( child_list, i );
			child_glayer->parent = NULL;
			return 0;
		}
	}
	child_glayer->parent = NULL;
	return 0;
}
开发者ID:aem3372,项目名称:LCUI,代码行数:28,代码来源:graphlayer.c

示例11: LCUITimer_Free

/**
 * 释放定时器
 * 当不需要定时器时,可以使用该函数释放定时器占用的资源
 * @param timer_id
 *	需要释放的定时器的标识符
 * @return
 *	正常返回0,指定ID的定时器不存在则返回-1.
 * */
LCUI_API int LCUITimer_Free( int timer_id )
{
	int i, total;
	timer_data *timer;
	
	LCUISleeper_BreakSleep( &timer_sleeper );
	Queue_Lock( &global_timer_list );
	total = Queue_GetTotal( &global_timer_list );
	for(i=0; i<total; ++i) {
		timer = (timer_data*)Queue_Get( &global_timer_list, i );
		if( !timer ) {
			continue;
		}
		if( timer->id == timer_id ) {
			DEBUG_MSG("delete timer: %d, n_ms: %d\n", timer->id, timer->total_ms);
			Queue_Delete( &global_timer_list, i );
			break;
		}
	}
	Queue_Unlock( &global_timer_list );
	if( i < total ) {
		LCUISleeper_BreakSleep( &timer_sleeper );
		return 0;
	}
	return -1;
}
开发者ID:fshunj,项目名称:LCUI,代码行数:34,代码来源:timer.c

示例12: StyleTag_Delete

/** 将指定标签的样式数据从队列中删除,只删除队列尾部第一个匹配的标签 */
static void StyleTag_Delete( LCUI_Queue *tags, StyleTag_ID tag )
{
	int i, total;
	StyleTag_Data *p; 
	 
	total = Queue_GetTotal( tags );
	DEBUG_MSG("delete start, total tag: %d\n", Queue_GetTotal( tags ));
	if(total <= 0) {
		return;
	}
	for(i=total-1; i>=0; --i) {
		p = Queue_Get( tags, i );
		if( p->tag == tag ) {
			Queue_Delete( tags, i );
			break;
		}
	} 
	DEBUG_MSG("delete end, total tag: %d\n", Queue_GetTotal( tags ));
}
开发者ID:gateslu,项目名称:LCUI,代码行数:20,代码来源:textstyle.c

示例13: StyleTag_GetCurrentStyle

/** 获取当前的样式数据 */
LCUI_API LCUI_TextStyle* StyleTag_GetCurrentStyle( LCUI_Queue *tags )
{
	PX_PT_t pxpt;
	StyleTag_Data *tag_data;
	LCUI_TextStyle *style_data;
	int i, total, equal = 0, flags[MAX_TAG_NUM];
	
	style_data = malloc (sizeof(LCUI_TextStyle));
	TextStyle_Init( style_data );
	memset( flags, 0, sizeof(flags) );
	
	total = Queue_GetTotal( tags );
	if(total <= 0) {
		free( style_data );
		return NULL;
	}
	
	/* 从样式数据队列中获取字体样式数据 */
	for(equal=0,i=total-1; i>=0; --i) {
		tag_data = Queue_Get( tags, i );
		DEBUG_MSG("tag id: %d\n", tag_data->tag);
		switch( tag_data->tag ) {
		    case TAG_ID_COLOR: 
			if( flags[0] != 0 ) {
				break;
			}
			style_data->_fore_color = TRUE;
			style_data->fore_color = *((LCUI_RGB*)tag_data->style);
			DEBUG_MSG("color: %d,%d,%d\n", data->fore_color.red,
			 data->fore_color.green, data->fore_color.blue);
			flags[0] = 1;
			++equal;
			break;
		    case TAG_ID_SIZE:
			if( flags[1] != 0 ) {
				break;
			}
			pxpt = *((PX_PT_t*)tag_data->style);
			style_data->_pixel_size = TRUE;
			style_data->pixel_size = pxpt.px;
			flags[1] = 1;
			++equal;
			break;
		    default: break;
		}
		if(equal == MAX_TAG_NUM) {
			break;
		}
	}
	if( equal == 0 ) {
		free( style_data );
		return NULL;
	}
	return style_data;
}
开发者ID:gateslu,项目名称:LCUI,代码行数:56,代码来源:textstyle.c

示例14: __GraphLayer_GetLayers

static int 
__GraphLayer_GetLayers(
	LCUI_GraphLayer *root_glayer,
	LCUI_GraphLayer *glayer, 
	LCUI_Rect rect, LCUI_Queue *queue )
{
	int i, total;
	LCUI_Pos pos;
	LCUI_Rect tmp;
	LCUI_GraphLayer *child; 
	LCUI_Queue *child_list;

	if( !glayer ) {
		//_DEBUG_MSG("!glayer\n");
		return -1;
	}
	if( !glayer->visible ) {
		//_DEBUG_MSG("!glayer_visible\n");
		return 1;
	}
	child_list = &glayer->child;
	/* 从底到顶遍历子部件 */
	total = Queue_GetTotal( child_list );
	//_DEBUG_MSG( "root: %p, cur: %p, child total: %d\n",
	//		root_glayer, glayer, total );
	/* 从尾到首,从底到顶,遍历图层 */
	for( i=total-1; i>=0; --i ) {
		child = (LCUI_GraphLayer*)Queue_Get( child_list, i );
		/* 忽略无效或不可见的图层 */
		if( !child || !child->visible ) {
			continue;
		}
		/* 获取子图层的有效区域及全局坐标 */
		tmp = GraphLayer_GetValidRect( root_glayer, child );
		pos = GraphLayer_GetGlobalPos( root_glayer, child );
		//_DEBUG_MSG( "child: %p, pos: %d,%d, valid rect: %d,%d, %d, %d\n", 
		//	child, pos.x, pos.y, tmp.x, tmp.y, tmp.width, tmp.height);
		//Graph_PrintInfo( &child->graph );
		/* 有效区域加上子部件的全局坐标 */
		tmp.x += pos.x;
		tmp.y += pos.y;
		/* 判断区域是否有效 */
		if( !LCUIRect_IsValid(tmp) ) {
			continue;
		}
		/* 若该有效区域与目标区域重叠,则记录子部件,并进行递归 */
		if( LCUIRect_Overlay(tmp, rect) ) {
			Queue_AddPointer( queue, child );
			__GraphLayer_GetLayers(	root_glayer, 
						child, rect, queue );
		}
	}
	return 0;
}
开发者ID:gateslu,项目名称:LCUI,代码行数:54,代码来源:LCUI_GraphLayer.c

示例15: LCUIApp_HaveTask

static LCUI_BOOL
LCUIApp_HaveTask( LCUI_App *app )
{
	if( !app ) {
		return FALSE; 
	}
	if(Queue_GetTotal(&app->tasks) > 0) {
		return TRUE; 
	}
	return FALSE;
}
开发者ID:yydaor,项目名称:LCUI,代码行数:11,代码来源:main.c


注:本文中的Queue_GetTotal函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。