eventq.cc (5503:cf464d02bc57) | eventq.cc (5602:9abcc140f346) |
---|---|
1/* 2 * Copyright (c) 2000-2005 The Regents of The University of Michigan 3 * Copyright (c) 2008 The Hewlett-Packard Development Company 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 43 unchanged lines hidden (view full) --- 52// cycle, before the pipeline simulation is performed. 53// 54EventQueue mainEventQueue("MainEventQueue"); 55 56#ifndef NDEBUG 57Counter Event::instanceCounter = 0; 58#endif 59 | 1/* 2 * Copyright (c) 2000-2005 The Regents of The University of Michigan 3 * Copyright (c) 2008 The Hewlett-Packard Development Company 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 43 unchanged lines hidden (view full) --- 52// cycle, before the pipeline simulation is performed. 53// 54EventQueue mainEventQueue("MainEventQueue"); 55 56#ifndef NDEBUG 57Counter Event::instanceCounter = 0; 58#endif 59 |
60inline Event * 61insertBefore(Event *event, Event *curr) | 60Event * 61Event::insertBefore(Event *event, Event *curr) |
62{ 63 // Either way, event will be the top element in the 'in bin' list 64 // which is the pointer we need in order to look into the list, so 65 // we need to insert that into the bin list. 66 if (!curr || *event < *curr) { 67 // Insert the event before the current list since it is in the future. 68 event->nextBin = curr; 69 event->nextInBin = NULL; --- 8 unchanged lines hidden (view full) --- 78 return event; 79} 80 81void 82EventQueue::insert(Event *event) 83{ 84 // Deal with the head case 85 if (!head || *event <= *head) { | 62{ 63 // Either way, event will be the top element in the 'in bin' list 64 // which is the pointer we need in order to look into the list, so 65 // we need to insert that into the bin list. 66 if (!curr || *event < *curr) { 67 // Insert the event before the current list since it is in the future. 68 event->nextBin = curr; 69 event->nextInBin = NULL; --- 8 unchanged lines hidden (view full) --- 78 return event; 79} 80 81void 82EventQueue::insert(Event *event) 83{ 84 // Deal with the head case 85 if (!head || *event <= *head) { |
86 head = insertBefore(event, head); | 86 head = Event::insertBefore(event, head); |
87 return; 88 } 89 90 // Figure out either which 'in bin' list we are on, or where a new list 91 // needs to be inserted 92 Event *prev = head; 93 Event *curr = head->nextBin; 94 while (curr && *curr < *event) { 95 prev = curr; 96 curr = curr->nextBin; 97 } 98 99 // Note: this operation may render all nextBin pointers on the 100 // prev 'in bin' list stale (except for the top one) | 87 return; 88 } 89 90 // Figure out either which 'in bin' list we are on, or where a new list 91 // needs to be inserted 92 Event *prev = head; 93 Event *curr = head->nextBin; 94 while (curr && *curr < *event) { 95 prev = curr; 96 curr = curr->nextBin; 97 } 98 99 // Note: this operation may render all nextBin pointers on the 100 // prev 'in bin' list stale (except for the top one) |
101 prev->nextBin = insertBefore(event, curr); | 101 prev->nextBin = Event::insertBefore(event, curr); |
102} 103 | 102} 103 |
104inline Event * 105removeItem(Event *event, Event *top) | 104Event * 105Event::removeItem(Event *event, Event *top) |
106{ 107 Event *curr = top; 108 Event *next = top->nextInBin; 109 110 // if we removed the top item, we need to handle things specially 111 // and just remove the top item, fixing up the next bin pointer of 112 // the new top item 113 if (event == top) { --- 22 unchanged lines hidden (view full) --- 136EventQueue::remove(Event *event) 137{ 138 if (head == NULL) 139 panic("event not found!"); 140 141 // deal with an event on the head's 'in bin' list (event has the same 142 // time as the head) 143 if (*head == *event) { | 106{ 107 Event *curr = top; 108 Event *next = top->nextInBin; 109 110 // if we removed the top item, we need to handle things specially 111 // and just remove the top item, fixing up the next bin pointer of 112 // the new top item 113 if (event == top) { --- 22 unchanged lines hidden (view full) --- 136EventQueue::remove(Event *event) 137{ 138 if (head == NULL) 139 panic("event not found!"); 140 141 // deal with an event on the head's 'in bin' list (event has the same 142 // time as the head) 143 if (*head == *event) { |
144 head = removeItem(event, head); | 144 head = Event::removeItem(event, head); |
145 return; 146 } 147 148 // Find the 'in bin' list that this event belongs on 149 Event *prev = head; 150 Event *curr = head->nextBin; 151 while (curr && *curr < *event) { 152 prev = curr; 153 curr = curr->nextBin; 154 } 155 156 if (!curr || *curr != *event) 157 panic("event not found!"); 158 159 // curr points to the top item of the the correct 'in bin' list, when 160 // we remove an item, it returns the new top item (which may be 161 // unchanged) | 145 return; 146 } 147 148 // Find the 'in bin' list that this event belongs on 149 Event *prev = head; 150 Event *curr = head->nextBin; 151 while (curr && *curr < *event) { 152 prev = curr; 153 curr = curr->nextBin; 154 } 155 156 if (!curr || *curr != *event) 157 panic("event not found!"); 158 159 // curr points to the top item of the the correct 'in bin' list, when 160 // we remove an item, it returns the new top item (which may be 161 // unchanged) |
162 prev->nextBin = removeItem(event, curr); | 162 prev->nextBin = Event::removeItem(event, curr); |
163} 164 165Event * 166EventQueue::serviceOne() 167{ 168 Event *event = head; 169 Event *next = head->nextInBin; 170 event->clearFlags(Event::Scheduled); --- 219 unchanged lines hidden --- | 163} 164 165Event * 166EventQueue::serviceOne() 167{ 168 Event *event = head; 169 Event *next = head->nextInBin; 170 event->clearFlags(Event::Scheduled); --- 219 unchanged lines hidden --- |