【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: 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