sched/event: Implement nxevent_timeout with nxevent_wait_irq

Implement nxevent_timeout with nxevent_wait_irq to remove
   code duplication

Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
This commit is contained in:
wangchengdong
2025-10-29 10:41:12 +08:00
committed by Alan C. Assis
parent 39f54c1524
commit 94cfb1180b

View File

@@ -75,33 +75,7 @@ static void nxevent_timeout(wdparm_t arg)
if (wtcb->task_state == TSTATE_WAIT_EVENT)
{
/* Remove the wait from the event's waiting list */
if (list_in_list(&(wait->node)))
{
list_delete(&(wait->node));
}
wtcb->waitobj = NULL;
/* Mark the errno value for the thread. */
wtcb->errcode = ETIMEDOUT;
FAR struct tcb_s *rtcb = this_task();
/* Remove the task from waiting list */
dq_rem((FAR dq_entry_t *)wtcb, list_waitingforsignal());
/* Add the task to ready-to-run task list, and
* perform the context switch if one is needed
*/
if (nxsched_add_readytorun(wtcb))
{
up_switch_context(this_task(), rtcb);
}
nxevent_wait_irq(wtcb, ETIMEDOUT);
}
leave_critical_section(flags);