From 43cd693fe07b16467b2d66cc9678dfcb63ff485c Mon Sep 17 00:00:00 2001 From: Yury Gribov Date: Sun, 10 Jul 2016 20:37:35 +0100 Subject: [PATCH] Put start events to proper queue. --- vvp/schedule.cc | 70 ++++++++++++------------------------------------- 1 file changed, 17 insertions(+), 53 deletions(-) diff --git a/vvp/schedule.cc b/vvp/schedule.cc index 5e176ac14..577c0f983 100644 --- a/vvp/schedule.cc +++ b/vvp/schedule.cc @@ -725,78 +725,42 @@ static void schedule_event_(struct event_s*cur, vvp_time64_t delay, receive the event at hand. Put the event in to the appropriate list for the kind of assign we have at hand. */ - switch (select_queue) { + struct event_s** q = 0; + switch (select_queue) { case SEQ_START: - if (ctim->start == 0) { - ctim->start = cur; - } else { - cur->next = ctim->active->next; - ctim->active->next = cur; - ctim->active = cur; - } + q = &ctim->start; break; case SEQ_ACTIVE: - if (ctim->active == 0) { - ctim->active = cur; - - } else { - /* Put the cur event on the end of the active list. */ - cur->next = ctim->active->next; - ctim->active->next = cur; - ctim->active = cur; - } + q = &ctim->active; break; case SEQ_NBASSIGN: - if (ctim->nbassign == 0) { - ctim->nbassign = cur; - - } else { - /* Put the cur event on the end of the active list. */ - cur->next = ctim->nbassign->next; - ctim->nbassign->next = cur; - ctim->nbassign = cur; - } + q = &ctim->nbassign; break; case SEQ_RWSYNC: - if (ctim->rwsync == 0) { - ctim->rwsync = cur; - - } else { - /* Put the cur event on the end of the active list. */ - cur->next = ctim->rwsync->next; - ctim->rwsync->next = cur; - ctim->rwsync = cur; - } + q = &ctim->rwsync; break; case SEQ_ROSYNC: - if (ctim->rosync == 0) { - ctim->rosync = cur; - - } else { - /* Put the cur event on the end of the active list. */ - cur->next = ctim->rosync->next; - ctim->rosync->next = cur; - ctim->rosync = cur; - } + q = &ctim->rosync; break; case DEL_THREAD: - if (ctim->del_thr == 0) { - ctim->del_thr = cur; - - } else { - /* Put the cur event on the end of the active list. */ - cur->next = ctim->del_thr->next; - ctim->del_thr->next = cur; - ctim->del_thr = cur; - } + q = &ctim->del_thr; break; } + + if (q) { + if (*q) { + /* Put the cur event on the end of the queue. */ + cur->next = (*q)->next; + (*q)->next = cur; + } + *q = cur; + } } static void schedule_event_push_(struct event_s*cur)