【C语言】一种状态超时阻塞循环查询的办法

2024-01-07 18:59:17

【C语言】一种状态超时阻塞循环查询的办法

1.方法1

在这里插入图片描述

static void wait_notify_async(notify_type_t notify_type)
{
   
	static rt_tick_t exit_tick;
	exit_tick = rt_time_get_msec();
	lb_int32 notify_success = RT_FALSE;
	static int timeout;

    CHKPNT;
	while (notify_success == RT_FALSE) {
   
		switch (notify_type) {
   
		case ADAS_EXITED:
			if (algorithm_status.adas_status == 2)
				notify_success = RT_TRUE;
			break;
		case BSD_EXITED:
			if (algorithm_status.bsd_status == 2)
				notify_success = RT_TRUE;
			break;
		case DMS_EXITED:
			if (algorithm_status.bsd_status == 2)
				notify_success = RT_TRUE;
			break;
		case RECORD_EXITED:
		    //CHKPNT;
			if (record_status == 2)
				notify_success = RT_TRUE;
			break;
		case TAKE_PICTURE_STATUS:
			if (take_picure_status > 0)
				notify_success = RT_TRUE;
			break;
		default:
			break;
		}
		timeout = rt_time_get_msec() - exit_tick;
		if (timeout >= 10 * 1000)
			break;
		rt_thread_mdelay(10

文章来源:https://blog.csdn.net/I_feige/article/details/135436455
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。