Deleted Added
sdiff udiff text old ( 9159:8adc048515b8 ) new ( 9356:b279bad40aa3 )
full compact
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;

--- 30 unchanged lines hidden (view full) ---

39#include <algorithm>
40#include <cassert>
41#include <climits>
42#include <iosfwd>
43#include <string>
44
45#include "base/flags.hh"
46#include "base/misc.hh"
47#include "base/types.hh"
48#include "debug/Event.hh"
49#include "sim/serialize.hh"
50
51class EventQueue; // forward declaration
52
53extern EventQueue mainEventQueue;
54

--- 300 unchanged lines hidden (view full) ---

355/*
356 * Queue of events sorted in time order
357 */
358class EventQueue : public Serializable
359{
360 private:
361 std::string objName;
362 Event *head;
363 Tick _curTick;
364
365 void insert(Event *event);
366 void remove(Event *event);
367
368 EventQueue(const EventQueue &);
369 const EventQueue &operator=(const EventQueue &);
370
371 public:
372 EventQueue(const std::string &n);
373
374 virtual const std::string name() const { return objName; }
375
376 // schedule the given event on this queue
377 void schedule(Event *event, Tick when);
378 void deschedule(Event *event);
379 void reschedule(Event *event, Tick when, bool always = false);
380
381 Tick nextTick() const { return head->when(); }
382 void setCurTick(Tick newVal) { _curTick = newVal; }
383 Tick getCurTick() { return _curTick; }
384
385 Event *serviceOne();
386
387 // process all events up to the given timestamp. we inline a
388 // quick test to see if there are any events to process; if so,
389 // call the internal out-of-line version to process them all.
390 void
391 serviceEvents(Tick when)
392 {
393 while (!empty()) {
394 if (nextTick() > when)
395 break;
396
397 /**
398 * @todo this assert is a good bug catcher. I need to
399 * make it true again.
400 */
401 //assert(head->when() >= when && "event scheduled in the past");
402 serviceOne();
403 }
404
405 setCurTick(when);
406 }
407
408 // return true if no events are queued
409 bool empty() const { return head == NULL; }
410
411 void dump() const;
412
413 bool debugVerify() const;

--- 62 unchanged lines hidden (view full) ---

476 eventq->deschedule(event);
477 }
478
479 void
480 reschedule(Event *event, Tick when, bool always = false)
481 {
482 eventq->reschedule(event, when, always);
483 }
484
485 void setCurTick(Tick newVal) { eventq->setCurTick(newVal); }
486};
487
488template <class T, void (T::* F)()>
489void
490DelayFunction(EventQueue *eventq, Tick when, T *object)
491{
492 class DelayEvent : public Event
493 {
494 private:
495 T *object;

--- 46 unchanged lines hidden ---