eventq.hh (7066:5389824adf3d) | eventq.hh (7823:dac01f14f20f) |
---|---|
1/* 2 * Copyright (c) 2000-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 122 unchanged lines hidden (view full) --- 131 void 132 setWhen(Tick when, EventQueue *q) 133 { 134 _when = when; 135#ifndef NDEBUG 136 queue = q; 137#endif 138#ifdef EVENTQ_DEBUG | 1/* 2 * Copyright (c) 2000-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 122 unchanged lines hidden (view full) --- 131 void 132 setWhen(Tick when, EventQueue *q) 133 { 134 _when = when; 135#ifndef NDEBUG 136 queue = q; 137#endif 138#ifdef EVENTQ_DEBUG |
139 whenScheduled = curTick; | 139 whenScheduled = curTick(); |
140#endif 141 } 142 143 protected: 144 /// Accessor for flags. 145 Flags 146 getFlags() const 147 { --- 101 unchanged lines hidden (view full) --- 249 Event(Priority p = Default_Pri) 250 : nextBin(NULL), nextInBin(NULL), _priority(p), flags(Initialized) 251 { 252#ifndef NDEBUG 253 instance = ++instanceCounter; 254 queue = NULL; 255#endif 256#ifdef EVENTQ_DEBUG | 140#endif 141 } 142 143 protected: 144 /// Accessor for flags. 145 Flags 146 getFlags() const 147 { --- 101 unchanged lines hidden (view full) --- 249 Event(Priority p = Default_Pri) 250 : nextBin(NULL), nextInBin(NULL), _priority(p), flags(Initialized) 251 { 252#ifndef NDEBUG 253 instance = ++instanceCounter; 254 queue = NULL; 255#endif 256#ifdef EVENTQ_DEBUG |
257 whenCreated = curTick; | 257 whenCreated = curTick(); |
258 whenScheduled = 0; 259#endif 260 } 261 262 virtual ~Event(); 263 virtual const std::string name() const; 264 265 /// Return a C string describing the event. This string should --- 134 unchanged lines hidden (view full) --- 400 * @todo this assert is a good bug catcher. I need to 401 * make it true again. 402 */ 403 //assert(head->when() >= when && "event scheduled in the past"); 404 serviceOne(); 405 } 406 } 407 | 258 whenScheduled = 0; 259#endif 260 } 261 262 virtual ~Event(); 263 virtual const std::string name() const; 264 265 /// Return a C string describing the event. This string should --- 134 unchanged lines hidden (view full) --- 400 * @todo this assert is a good bug catcher. I need to 401 * make it true again. 402 */ 403 //assert(head->when() >= when && "event scheduled in the past"); 404 serviceOne(); 405 } 406 } 407 |
408 // default: process all events up to 'now' (curTick) 409 void serviceEvents() { serviceEvents(curTick); } | 408 // default: process all events up to 'now' (curTick()) 409 void serviceEvents() { serviceEvents(curTick()); } |
410 411 // return true if no events are queued 412 bool empty() const { return head == NULL; } 413 414 void dump() const; 415 | 410 411 // return true if no events are queued 412 bool empty() const { return head == NULL; } 413 414 void dump() const; 415 |
416 Tick nextEventTime() { return empty() ? curTick : head->when(); } | 416 Tick nextEventTime() { return empty() ? curTick() : head->when(); } |
417 418 bool debugVerify() const; 419 420#ifndef SWIG 421 virtual void serialize(std::ostream &os); 422 virtual void unserialize(Checkpoint *cp, const std::string §ion); 423#endif 424}; --- 56 unchanged lines hidden (view full) --- 481 { 482 eventq->reschedule(event, when, always); 483 } 484}; 485 486inline void 487EventQueue::schedule(Event *event, Tick when) 488{ | 417 418 bool debugVerify() const; 419 420#ifndef SWIG 421 virtual void serialize(std::ostream &os); 422 virtual void unserialize(Checkpoint *cp, const std::string §ion); 423#endif 424}; --- 56 unchanged lines hidden (view full) --- 481 { 482 eventq->reschedule(event, when, always); 483 } 484}; 485 486inline void 487EventQueue::schedule(Event *event, Tick when) 488{ |
489 assert((UTick)when >= (UTick)curTick); | 489 assert((UTick)when >= (UTick)curTick()); |
490 assert(!event->scheduled()); 491 assert(event->initialized()); 492 493 event->setWhen(when, this); 494 insert(event); 495 event->flags.set(Event::Scheduled); 496 if (this == &mainEventQueue) 497 event->flags.set(Event::IsMainQueue); --- 20 unchanged lines hidden (view full) --- 518 519 if (DTRACE(Event)) 520 event->trace("descheduled"); 521} 522 523inline void 524EventQueue::reschedule(Event *event, Tick when, bool always) 525{ | 490 assert(!event->scheduled()); 491 assert(event->initialized()); 492 493 event->setWhen(when, this); 494 insert(event); 495 event->flags.set(Event::Scheduled); 496 if (this == &mainEventQueue) 497 event->flags.set(Event::IsMainQueue); --- 20 unchanged lines hidden (view full) --- 518 519 if (DTRACE(Event)) 520 event->trace("descheduled"); 521} 522 523inline void 524EventQueue::reschedule(Event *event, Tick when, bool always) 525{ |
526 assert(when >= curTick); | 526 assert(when >= curTick()); |
527 assert(always || event->scheduled()); 528 assert(event->initialized()); 529 530 if (event->scheduled()) 531 remove(event); 532 533 event->setWhen(when, this); 534 insert(event); --- 65 unchanged lines hidden --- | 527 assert(always || event->scheduled()); 528 assert(event->initialized()); 529 530 if (event->scheduled()) 531 remove(event); 532 533 event->setWhen(when, this); 534 insert(event); --- 65 unchanged lines hidden --- |