00001 00002 #include "eventID.h" 00003 #include "pose.h" 00004 00006 void CancelList::RemoveItem(CancelNode *item) 00007 { 00008 POSE_TimeType isEarliest = (item->timestamp == earliest); 00009 CancelNode *tmp = cancellations; 00010 if (item == tmp) { // item is at front 00011 cancellations = cancellations->next; 00012 if (item == current) current = cancellations; 00013 delete item; 00014 } 00015 else { // search for the item 00016 while (tmp && (tmp->next != item)) 00017 tmp = tmp->next; 00018 if (!tmp) CkPrintf("ERROR: CancelList::RemoveItem: item not found\n"); 00019 tmp->next = item->next; 00020 if (item == current) current = tmp->next; 00021 if (!current) current = cancellations; 00022 delete item; 00023 } 00024 count--; 00025 if (isEarliest) { // item had earliest timestamp; recalculate earliest 00026 earliest = POSE_UnsetTS; 00027 tmp = cancellations; 00028 while (tmp) { 00029 if ((tmp->timestamp < earliest) || (earliest < 0)) 00030 earliest = tmp->timestamp; 00031 tmp = tmp->next; 00032 } 00033 } 00034 } 00035 00037 void CancelList::dump() 00038 { 00039 CancelNode *tmp = cancellations; 00040 #if USE_LONG_TIMESTAMPS 00041 if (!tmp) CkPrintf("[[Earliest=%lld of %d CANCELS: NULL]\n", earliest, count); 00042 #else 00043 if (!tmp) CkPrintf("[[Earliest=%d of %d CANCELS: NULL]\n", earliest, count); 00044 #endif 00045 else { 00046 #if USE_LONG_TIMESTAMPS 00047 CkPrintf("[Earliest=%lld of %d CANCELS: ", earliest, count); 00048 #else 00049 CkPrintf("[Earliest=%d of %d CANCELS: ", earliest, count); 00050 #endif 00051 while (tmp) { 00052 tmp->dump(); 00053 tmp = tmp->next; 00054 } 00055 CkPrintf("]\n"); 00056 } 00057 } 00058 00060 void CancelList::pup(PUP::er &p) 00061 { 00062 int i; 00063 CancelNode *tmp = NULL; 00064 p(count); p(earliest); 00065 if (p.isUnpacking()) { 00066 i = count; 00067 if (i == 0) { 00068 cancellations = NULL; 00069 } 00070 else { 00071 while (i > 0) { 00072 if (i == count) { 00073 tmp = new CancelNode; 00074 tmp->pup(p); 00075 cancellations = tmp; 00076 } 00077 else { 00078 tmp->next = new CancelNode; 00079 tmp = tmp->next; 00080 tmp->pup(p); 00081 } 00082 i--; 00083 } 00084 tmp->next = NULL; 00085 } 00086 current = cancellations; 00087 } 00088 else { 00089 i = count; 00090 tmp = cancellations; 00091 while (i > 0) { 00092 tmp->pup(p); 00093 tmp = tmp->next; 00094 i--; 00095 } 00096 } 00097 } 00098